summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormillert <>2005-07-27 14:16:43 +0000
committermillert <>2005-07-27 14:16:43 +0000
commitfa31c594590c7a2ab760e6d67f00a2ecf61bdfe9 (patch)
tree48651b0087d94501d6be0e71e15fa10fb4734fcf /src
parent83e5ea9ca26f62ac2a097f1b81ac7843caa2c864 (diff)
downloadopenbsd-fa31c594590c7a2ab760e6d67f00a2ecf61bdfe9.tar.gz
openbsd-fa31c594590c7a2ab760e6d67f00a2ecf61bdfe9.tar.bz2
openbsd-fa31c594590c7a2ab760e6d67f00a2ecf61bdfe9.zip
Restore recent changes except for the actual one that causes the problem.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libc/net/gethostnamadr.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/src/lib/libc/net/gethostnamadr.c b/src/lib/libc/net/gethostnamadr.c
index 4450652167..c984fac7b1 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.66 2005/07/27 13:40:28 jaredy Exp $"; 51static const char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.67 2005/07/27 14:16:43 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>
@@ -786,7 +786,7 @@ _endhtent(void)
786 } 786 }
787} 787}
788 788
789struct hostent * 789static struct hostent *
790_gethtent(void) 790_gethtent(void)
791{ 791{
792 struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res); 792 struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res);
@@ -832,9 +832,9 @@ _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) 835 if (host.h_addrtype != AF_UNSPEC && host.h_addrtype != af)
836 goto again; 836 goto again;
837 if (host.h_length != len) 837 if (host.h_length != 0 && host.h_length != len)
838 goto again; 838 goto again;
839 h_addr_ptrs[0] = (char *)host_addr; 839 h_addr_ptrs[0] = (char *)host_addr;
840 h_addr_ptrs[1] = NULL; 840 h_addr_ptrs[1] = NULL;
@@ -869,21 +869,6 @@ _gethtent(void)
869} 869}
870 870
871struct hostent * 871struct hostent *
872_gethtbyname(const char *name)
873{
874 struct __res_state *_resp = _THREAD_PRIVATE(_res, _res, &_res);
875 struct hostent *hp;
876 extern struct hostent *_gethtbyname2(const char *, int);
877
878 if (_resp->options & RES_USE_INET6) {
879 hp = _gethtbyname2(name, AF_INET6);
880 if (hp)
881 return (hp);
882 }
883 return (_gethtbyname2(name, AF_INET));
884}
885
886struct hostent *
887_gethtbyname2(const char *name, int af) 872_gethtbyname2(const char *name, int af)
888{ 873{
889 struct hostent *p; 874 struct hostent *p;
@@ -914,7 +899,8 @@ _gethtbyaddr(const void *addr, socklen_t len, int af)
914 899
915 _sethtent(0); 900 _sethtent(0);
916 while ((p = _gethtent())) 901 while ((p = _gethtent()))
917 if (p->h_addrtype == af && !bcmp(p->h_addr, addr, len)) 902 if (p->h_addrtype == af && p->h_length == len &&
903 !bcmp(p->h_addr, addr, len))
918 break; 904 break;
919 _endhtent(); 905 _endhtent();
920 return (p); 906 return (p);
@@ -1093,6 +1079,8 @@ map_v4v6_hostent(struct hostent *hp, char **bpp, char *ep)
1093struct hostent * 1079struct hostent *
1094gethostent(void) 1080gethostent(void)
1095{ 1081{
1082 host.h_addrtype = AF_UNSPEC;
1083 host.h_length = 0;
1096 return (_gethtent()); 1084 return (_gethtent());
1097} 1085}
1098 1086