diff options
author | Enji Cooper <ngie@FreeBSD.org> | 2015-11-26 07:58:22 +0000 |
---|---|---|
committer | Enji Cooper <ngie@FreeBSD.org> | 2015-11-26 07:58:22 +0000 |
commit | a6961d88b46d28a6f2fb82239d26977af741d038 (patch) | |
tree | 48877a87419195f1c21e7c9f1dc917d2a8b37218 /tools/regression/lib/libc | |
parent | 059d81a6e4f0b6344869d453a64727f42fa699b9 (diff) | |
download | src-a6961d88b46d28a6f2fb82239d26977af741d038.tar.gz src-a6961d88b46d28a6f2fb82239d26977af741d038.zip |
r291359 was incorrect. Skip over tokens that start with `#' as fgetln can
return more than one '\n' delimited line in a buffer
Handle empty lines too, just in case
MFC after: 3 days
X-MFC with: r291359
Notes
Notes:
svn path=/head/; revision=291362
Diffstat (limited to 'tools/regression/lib/libc')
-rw-r--r-- | tools/regression/lib/libc/resolv/resolv.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/tools/regression/lib/libc/resolv/resolv.c b/tools/regression/lib/libc/resolv/resolv.c index 93928721eae1..2ec3eebd85da 100644 --- a/tools/regression/lib/libc/resolv/resolv.c +++ b/tools/regression/lib/libc/resolv/resolv.c @@ -87,13 +87,14 @@ load(const char *fname) if ((fp = fopen(fname, "r")) == NULL) err(1, "Cannot open `%s'", fname); while ((line = fgetln(fp, &len)) != NULL) { - if (line[0] == '#') - continue; char c = line[len]; char *ptr; line[len] = '\0'; - for (ptr = strtok(line, WS); ptr; ptr = strtok(NULL, WS)) + for (ptr = strtok(line, WS); ptr; ptr = strtok(NULL, WS)) { + if (ptr == '\0' || ptr[0] == '#') + continue; sl_add(hosts, strdup(ptr)); + } line[len] = c; } |