summaryrefslogtreecommitdiff
path: root/src/lib/libc/net/res_query.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc/net/res_query.c')
-rw-r--r--src/lib/libc/net/res_query.c15
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 @@
60static char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93"; 60static char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93";
61static char rcsid[] = "$From: res_query.c,v 8.9 1996/09/22 00:13:28 vixie Exp $"; 61static char rcsid[] = "$From: res_query.c,v 8.9 1996/09/22 00:13:28 vixie Exp $";
62#else 62#else
63static char rcsid[] = "$OpenBSD: res_query.c,v 1.10 1997/07/09 01:08:53 millert Exp $"; 63static 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)