summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorngie <ngie@FreeBSD.org>2015-11-26 07:55:20 +0000
committerngie <ngie@FreeBSD.org>2015-11-26 07:55:20 +0000
commit13fcf1f8c2ed94cbabd6a4bee12f8ffb806252c5 (patch)
tree2dfc923c3472e16e8c927ab2403879ce10604b2a /tools
parent6645852f9b29830203c009f70970b616db89800a (diff)
downloadFreeBSD-src-13fcf1f8c2ed94cbabd6a4bee12f8ffb806252c5.zip
FreeBSD-src-13fcf1f8c2ed94cbabd6a4bee12f8ffb806252c5.tar.gz
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
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/lib/libc/resolv/resolv.c7
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 9392872..2ec3eeb 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;
}
OpenPOWER on IntegriCloud