summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormillert <>2005-07-24 18:47:59 +0000
committermillert <>2005-07-24 18:47:59 +0000
commit784cdc2a0a4ce17f4ae227250d54312c4574847e (patch)
treeeb0cf00f08dc3ed1f673a01564de41c73162d6c4 /src
parent16995c81478ea86d9b0d1ed0b4ca140b296d023f (diff)
downloadopenbsd-784cdc2a0a4ce17f4ae227250d54312c4574847e.tar.gz
openbsd-784cdc2a0a4ce17f4ae227250d54312c4574847e.tar.bz2
openbsd-784cdc2a0a4ce17f4ae227250d54312c4574847e.zip
In _gethtent() ignore host.h_length if it is set to 0. Previously
we only ignored it if host.h_addrtype was AF_UNSPEC. Set host.h_length to 0 in _gethtbyname2() since that function does not take a length argument. Problem found by jaredy@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libc/net/gethostnamadr.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/lib/libc/net/gethostnamadr.c b/src/lib/libc/net/gethostnamadr.c
index 626f9a6e65..70bff68fd6 100644
--- a/src/lib/libc/net/gethostnamadr.c
+++ b/src/lib/libc/net/gethostnamadr.c
@@ -48,7 +48,7 @@
48 */ 48 */
49 49
50#if defined(LIBC_SCCS) && !defined(lint) 50#if defined(LIBC_SCCS) && !defined(lint)
51static const char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.64 2005/07/23 04:15:49 jaredy Exp $"; 51static const char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.65 2005/07/24 18:47:59 millert Exp $";
52#endif /* LIBC_SCCS and not lint */ 52#endif /* LIBC_SCCS and not lint */
53 53
54#include <sys/param.h> 54#include <sys/param.h>
@@ -832,12 +832,10 @@ _gethtent(void)
832 goto again; 832 goto again;
833 } 833 }
834 /* if this is not something we're looking for, skip it. */ 834 /* if this is not something we're looking for, skip it. */
835 if (host.h_addrtype != AF_UNSPEC) { 835 if (host.h_addrtype != AF_UNSPEC && host.h_addrtype != af)
836 if (host.h_addrtype != af) 836 goto again;
837 goto again; 837 if (host.h_length != 0 && host.h_length != len)
838 if (host.h_length != len) 838 goto again;
839 goto again;
840 }
841 h_addr_ptrs[0] = (char *)host_addr; 839 h_addr_ptrs[0] = (char *)host_addr;
842 h_addr_ptrs[1] = NULL; 840 h_addr_ptrs[1] = NULL;
843 host.h_addr_list = h_addr_ptrs; 841 host.h_addr_list = h_addr_ptrs;
@@ -877,11 +875,9 @@ _gethtbyname2(const char *name, int af)
877 char **cp; 875 char **cp;
878 876
879 host.h_addrtype = af; 877 host.h_addrtype = af;
880 878 host.h_length = 0;
881 _sethtent(0); 879 _sethtent(0);
882 while ((p = _gethtent())) { 880 while ((p = _gethtent())) {
883 if (p->h_addrtype != af)
884 continue;
885 if (strcasecmp(p->h_name, name) == 0) 881 if (strcasecmp(p->h_name, name) == 0)
886 break; 882 break;
887 for (cp = p->h_aliases; *cp != 0; cp++) 883 for (cp = p->h_aliases; *cp != 0; cp++)
@@ -1084,6 +1080,7 @@ struct hostent *
1084gethostent(void) 1080gethostent(void)
1085{ 1081{
1086 host.h_addrtype = AF_UNSPEC; 1082 host.h_addrtype = AF_UNSPEC;
1083 host.h_length = 0;
1087 return (_gethtent()); 1084 return (_gethtent());
1088} 1085}
1089 1086