diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-20 17:50:58 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-20 17:50:58 +0000 |
| commit | 9b366f41367f717d8ddd9909fdc710b92f92a16c (patch) | |
| tree | 8f84f7271f312b8658e0443ea723c20fcd1eb36f | |
| parent | a34f1ed737e79e494904706e59f4e7fbb49e32b3 (diff) | |
| download | busybox-w32-9b366f41367f717d8ddd9909fdc710b92f92a16c.tar.gz busybox-w32-9b366f41367f717d8ddd9909fdc710b92f92a16c.tar.bz2 busybox-w32-9b366f41367f717d8ddd9909fdc710b92f92a16c.zip | |
libbb/parse_config.c: fix small buglet (by Vladimir)
| -rw-r--r-- | libbb/parse_config.c | 4 | ||||
| -rwxr-xr-x | testsuite/parse.tests | 43 |
2 files changed, 45 insertions, 2 deletions
diff --git a/libbb/parse_config.c b/libbb/parse_config.c index 68caa2c37..3174a649e 100644 --- a/libbb/parse_config.c +++ b/libbb/parse_config.c | |||
| @@ -199,7 +199,8 @@ int FAST_FUNC config_read(parser_t *parser, char **tokens, unsigned flags, const | |||
| 199 | } else { | 199 | } else { |
| 200 | // vanilla token. cut the line at the first delim | 200 | // vanilla token. cut the line at the first delim |
| 201 | q = line + strcspn(line, delims); | 201 | q = line + strcspn(line, delims); |
| 202 | *q++ = '\0'; | 202 | if (*q) // watch out: do not step past the line end! |
| 203 | *q++ = '\0'; | ||
| 203 | } | 204 | } |
| 204 | // pin token | 205 | // pin token |
| 205 | if ((flags & (PARSE_DONT_REDUCE|PARSE_DONT_TRIM)) || *line) { | 206 | if ((flags & (PARSE_DONT_REDUCE|PARSE_DONT_TRIM)) || *line) { |
| @@ -207,6 +208,7 @@ int FAST_FUNC config_read(parser_t *parser, char **tokens, unsigned flags, const | |||
| 207 | tokens[ii++] = line; | 208 | tokens[ii++] = line; |
| 208 | } | 209 | } |
| 209 | line = q; | 210 | line = q; |
| 211 | //bb_info_msg("A[%s]", line); | ||
| 210 | } | 212 | } |
| 211 | 213 | ||
| 212 | if (ii < mintokens) | 214 | if (ii < mintokens) |
diff --git a/testsuite/parse.tests b/testsuite/parse.tests index 1b43f9c9f..06be8d2b9 100755 --- a/testsuite/parse.tests +++ b/testsuite/parse.tests | |||
| @@ -23,7 +23,7 @@ testing "notrim" \ | |||
| 23 | "-" \ | 23 | "-" \ |
| 24 | " sda 0:0 644 @echo @echo TEST \n" | 24 | " sda 0:0 644 @echo @echo TEST \n" |
| 25 | 25 | ||
| 26 | FILE=__parse.fstab | 26 | FILE=__parse |
| 27 | cat >$FILE <<EOF | 27 | cat >$FILE <<EOF |
| 28 | # | 28 | # |
| 29 | # Device Point System Options | 29 | # Device Point System Options |
| @@ -59,6 +59,47 @@ testing "polluted fstab" \ | |||
| 59 | "`cat $FILE.res`\n" \ | 59 | "`cat $FILE.res`\n" \ |
| 60 | "" \ | 60 | "" \ |
| 61 | "" | 61 | "" |
| 62 | cp ../examples/inittab $FILE | ||
| 63 | cat >$FILE.res <<EOF | ||
| 64 | [][][sysinit][/etc/init.d/rcS] | ||
| 65 | [][][askfirst][-/bin/sh] | ||
| 66 | [tty2][][askfirst][-/bin/sh] | ||
| 67 | [tty3][][askfirst][-/bin/sh] | ||
| 68 | [tty4][][askfirst][-/bin/sh] | ||
| 69 | [tty4][][respawn][/sbin/getty 38400 tty5] | ||
| 70 | [tty5][][respawn][/sbin/getty 38400 tty6] | ||
| 71 | [][][restart][/sbin/init] | ||
| 72 | [][][ctrlaltdel][/sbin/reboot] | ||
| 73 | [][][shutdown][/bin/umount -a -r] | ||
| 74 | [][][shutdown][/sbin/swapoff -a] | ||
| 75 | EOF | ||
| 76 | |||
| 77 | testing "inittab from examples" \ | ||
| 78 | "parse -n 4 -m 4 -f $(($GREEDY+$NO_TRIM)) -d'#:' $FILE" \ | ||
| 79 | "`cat $FILE.res`\n" \ | ||
| 80 | "" \ | ||
| 81 | "" | ||
| 82 | |||
| 83 | cp ../examples/udhcp/udhcpd.conf $FILE | ||
| 84 | cat >$FILE.res <<EOF | ||
| 85 | [start][192.168.0.20] | ||
| 86 | [end][192.168.0.254] | ||
| 87 | [interface][eth0] | ||
| 88 | [opt][dns][192.168.10.2][192.168.10.10] | ||
| 89 | [option][subnet][255.255.255.0] | ||
| 90 | [opt][router][192.168.10.2] | ||
| 91 | [opt][wins][192.168.10.10] | ||
| 92 | [option][dns][129.219.13.81] | ||
| 93 | [option][domain][local] | ||
| 94 | [option][lease][864000] | ||
| 95 | EOF | ||
| 96 | |||
| 97 | testing "udhcpd.conf from examples" \ | ||
| 98 | "parse -n 127 $FILE" \ | ||
| 99 | "`cat $FILE.res`\n" \ | ||
| 100 | "" \ | ||
| 101 | "" | ||
| 102 | |||
| 62 | rm -f $FILE $FILE.res | 103 | rm -f $FILE $FILE.res |
| 63 | 104 | ||
| 64 | exit $FAILCOUNT | 105 | exit $FAILCOUNT |
