diff options
author | Eric Andersen <andersen@codepoet.org> | 2004-04-06 12:06:03 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2004-04-06 12:06:03 +0000 |
commit | 7e496a71cfe54f192508427f9c8ea5be764952bd (patch) | |
tree | 63e7bbabef905c096dde2f5f601c60c26d214c33 | |
parent | d298bd1d513ddf077c51df5f0dfb3a5b2d0c28ee (diff) | |
download | busybox-w32-7e496a71cfe54f192508427f9c8ea5be764952bd.tar.gz busybox-w32-7e496a71cfe54f192508427f9c8ea5be764952bd.tar.bz2 busybox-w32-7e496a71cfe54f192508427f9c8ea5be764952bd.zip |
Michael Tokarev, mjt at tls dot msk dot ru writes:
Fix parsing of all tag-value pairs (in modules.conf in particular).
Without this fix, code chokes badly on lines where either value or
both tag+value are missing, like bare
alias
line, or alias w/o the value like
alias some-module
(syntactically incorrect, but no need for coredumps either).
-rw-r--r-- | modutils/modprobe.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/modutils/modprobe.c b/modutils/modprobe.c index 7078af220..df5d4bbd1 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c | |||
@@ -67,15 +67,17 @@ int parse_tag_value ( char *buffer, char **ptag, char **pvalue ) | |||
67 | buffer++; | 67 | buffer++; |
68 | tag = value = buffer; | 68 | tag = value = buffer; |
69 | while ( !isspace ( *value )) | 69 | while ( !isspace ( *value )) |
70 | value++; | 70 | if (!*value) return 0; |
71 | else value++; | ||
71 | *value++ = 0; | 72 | *value++ = 0; |
72 | while ( isspace ( *value )) | 73 | while ( isspace ( *value )) |
73 | value++; | 74 | value++; |
75 | if (!*value) return 0; | ||
74 | 76 | ||
75 | *ptag = tag; | 77 | *ptag = tag; |
76 | *pvalue = value; | 78 | *pvalue = value; |
77 | 79 | ||
78 | return bb_strlen( tag ) && bb_strlen( value ); | 80 | return 1; |
79 | } | 81 | } |
80 | 82 | ||
81 | /* Jump through hoops to simulate how fgets() grabs just one line at a | 83 | /* Jump through hoops to simulate how fgets() grabs just one line at a |