diff options
author | millert <> | 1998-03-16 05:07:02 +0000 |
---|---|---|
committer | millert <> | 1998-03-16 05:07:02 +0000 |
commit | 7cc61258b3b66c62b0828fdaa234ee8ae2fee2dc (patch) | |
tree | d54fd8f615df82fffca9638aee76c24acf5b731f /src/lib/libc/net/res_query.c | |
parent | fcd822203d1ea91b0c87703a36e5819909a8f7f4 (diff) | |
download | openbsd-7cc61258b3b66c62b0828fdaa234ee8ae2fee2dc.tar.gz openbsd-7cc61258b3b66c62b0828fdaa234ee8ae2fee2dc.tar.bz2 openbsd-7cc61258b3b66c62b0828fdaa234ee8ae2fee2dc.zip |
Use fgetln(3) instead of fgets(3) so we can easily recognize lines
that are too long and ignore them instead of corrupting later entries.
Diffstat (limited to 'src/lib/libc/net/res_query.c')
-rw-r--r-- | src/lib/libc/net/res_query.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/lib/libc/net/res_query.c b/src/lib/libc/net/res_query.c index 2e245b78cc..a2a8fe000b 100644 --- a/src/lib/libc/net/res_query.c +++ b/src/lib/libc/net/res_query.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: res_query.c,v 1.10 1997/07/09 01:08:53 millert Exp $ */ | 1 | /* $OpenBSD: res_query.c,v 1.11 1998/03/16 05:07:02 millert Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * ++Copyright++ 1988, 1993 | 4 | * ++Copyright++ 1988, 1993 |
@@ -60,7 +60,7 @@ | |||
60 | static char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93"; | 60 | static char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93"; |
61 | static char rcsid[] = "$From: res_query.c,v 8.9 1996/09/22 00:13:28 vixie Exp $"; | 61 | static char rcsid[] = "$From: res_query.c,v 8.9 1996/09/22 00:13:28 vixie Exp $"; |
62 | #else | 62 | #else |
63 | static char rcsid[] = "$OpenBSD: res_query.c,v 1.10 1997/07/09 01:08:53 millert Exp $"; | 63 | static char rcsid[] = "$OpenBSD: res_query.c,v 1.11 1998/03/16 05:07:02 millert Exp $"; |
64 | #endif | 64 | #endif |
65 | #endif /* LIBC_SCCS and not lint */ | 65 | #endif /* LIBC_SCCS and not lint */ |
66 | 66 | ||
@@ -359,6 +359,7 @@ hostalias(name) | |||
359 | char *file; | 359 | char *file; |
360 | char buf[BUFSIZ]; | 360 | char buf[BUFSIZ]; |
361 | static char abuf[MAXDNAME]; | 361 | static char abuf[MAXDNAME]; |
362 | size_t len; | ||
362 | 363 | ||
363 | if (_res.options & RES_NOALIASES) | 364 | if (_res.options & RES_NOALIASES) |
364 | return (NULL); | 365 | return (NULL); |
@@ -366,8 +367,14 @@ hostalias(name) | |||
366 | if (issetugid() != 0 || file == NULL || (fp = fopen(file, "r")) == NULL) | 367 | if (issetugid() != 0 || file == NULL || (fp = fopen(file, "r")) == NULL) |
367 | return (NULL); | 368 | return (NULL); |
368 | setbuf(fp, NULL); | 369 | setbuf(fp, NULL); |
369 | buf[sizeof(buf) - 1] = '\0'; | 370 | while ((cp1 = fgetln(fp, &len)) != NULL) { |
370 | while (fgets(buf, sizeof(buf), fp)) { | 371 | if (cp1[len-1] == '\n') |
372 | len--; | ||
373 | if (len >= sizeof(buf) || len == 0) | ||
374 | continue; | ||
375 | (void)memcpy(buf, cp1, len); | ||
376 | buf[len] = '\0'; | ||
377 | |||
371 | for (cp1 = buf; *cp1 && !isspace(*cp1); ++cp1) | 378 | for (cp1 = buf; *cp1 && !isspace(*cp1); ++cp1) |
372 | ; | 379 | ; |
373 | if (!*cp1) | 380 | if (!*cp1) |