diff options
author | itojun <> | 2000-07-30 14:07:14 +0000 |
---|---|---|
committer | itojun <> | 2000-07-30 14:07:14 +0000 |
commit | 7858083b781b818094dfe3485ef0d19f4833cbf5 (patch) | |
tree | 17c412cf1cf8df1c777af5220bc9b1ad20e864a4 | |
parent | 432a3564e02a6a304ead04353f4574157274752d (diff) | |
download | openbsd-7858083b781b818094dfe3485ef0d19f4833cbf5.tar.gz openbsd-7858083b781b818094dfe3485ef0d19f4833cbf5.tar.bz2 openbsd-7858083b781b818094dfe3485ef0d19f4833cbf5.zip |
avoid buffer overrun on too-long reply for NIS hostname lookup.
-rw-r--r-- | src/lib/libc/net/gethostnamadr.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/lib/libc/net/gethostnamadr.c b/src/lib/libc/net/gethostnamadr.c index 47570f4a02..33c9643f70 100644 --- a/src/lib/libc/net/gethostnamadr.c +++ b/src/lib/libc/net/gethostnamadr.c | |||
@@ -52,7 +52,7 @@ | |||
52 | */ | 52 | */ |
53 | 53 | ||
54 | #if defined(LIBC_SCCS) && !defined(lint) | 54 | #if defined(LIBC_SCCS) && !defined(lint) |
55 | static char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.41 2000/01/06 08:24:17 d Exp $"; | 55 | static char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.42 2000/07/30 14:07:14 itojun Exp $"; |
56 | #endif /* LIBC_SCCS and not lint */ | 56 | #endif /* LIBC_SCCS and not lint */ |
57 | 57 | ||
58 | #include <sys/param.h> | 58 | #include <sys/param.h> |
@@ -954,14 +954,14 @@ _yphostent(line) | |||
954 | q = host.h_aliases = host_aliases; | 954 | q = host.h_aliases = host_aliases; |
955 | 955 | ||
956 | nextline: | 956 | nextline: |
957 | /* check for host_addrs overflow */ | ||
958 | if (buf >= &host_addrs[sizeof(host_addrs) / sizeof(host_addrs[0])]) | ||
959 | goto done; | ||
960 | |||
957 | more = 0; | 961 | more = 0; |
958 | cp = strpbrk(p, " \t"); | 962 | cp = strpbrk(p, " \t"); |
959 | if (cp == NULL) { | 963 | if (cp == NULL) |
960 | if (host.h_name == NULL) | 964 | goto done; |
961 | return (NULL); | ||
962 | else | ||
963 | goto done; | ||
964 | } | ||
965 | *cp++ = '\0'; | 965 | *cp++ = '\0'; |
966 | 966 | ||
967 | *hap++ = (char *)buf; | 967 | *hap++ = (char *)buf; |
@@ -1002,6 +1002,8 @@ nextline: | |||
1002 | *cp++ = '\0'; | 1002 | *cp++ = '\0'; |
1003 | } | 1003 | } |
1004 | done: | 1004 | done: |
1005 | if (host.h_name == NULL) | ||
1006 | return (NULL); | ||
1005 | *q = NULL; | 1007 | *q = NULL; |
1006 | *hap = NULL; | 1008 | *hap = NULL; |
1007 | return (&host); | 1009 | return (&host); |