summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaredy <>2005-07-27 13:40:28 +0000
committerjaredy <>2005-07-27 13:40:28 +0000
commit83e5ea9ca26f62ac2a097f1b81ac7843caa2c864 (patch)
tree679b330e81b655feaf72ec8272ff8d0a96f5418c
parent1193412fea3b4ec1d4cde49dd5606e858a48331b (diff)
downloadopenbsd-83e5ea9ca26f62ac2a097f1b81ac7843caa2c864.tar.gz
openbsd-83e5ea9ca26f62ac2a097f1b81ac7843caa2c864.tar.bz2
openbsd-83e5ea9ca26f62ac2a097f1b81ac7843caa2c864.zip
backout gethostent changes for now -- there is fallout, discovered by otto
-rw-r--r--src/lib/libc/net/gethostnamadr.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/lib/libc/net/gethostnamadr.c b/src/lib/libc/net/gethostnamadr.c
index 70bff68fd6..4450652167 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.65 2005/07/24 18:47:59 millert Exp $"; 51static const char rcsid[] = "$OpenBSD: gethostnamadr.c,v 1.66 2005/07/27 13:40:28 jaredy 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
789static struct hostent * 789struct 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_UNSPEC && host.h_addrtype != af) 835 if (host.h_addrtype != af)
836 goto again; 836 goto again;
837 if (host.h_length != 0 && host.h_length != len) 837 if (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,15 +869,30 @@ _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 *
872_gethtbyname2(const char *name, int af) 887_gethtbyname2(const char *name, int af)
873{ 888{
874 struct hostent *p; 889 struct hostent *p;
875 char **cp; 890 char **cp;
876 891
877 host.h_addrtype = af;
878 host.h_length = 0;
879 _sethtent(0); 892 _sethtent(0);
880 while ((p = _gethtent())) { 893 while ((p = _gethtent())) {
894 if (p->h_addrtype != af)
895 continue;
881 if (strcasecmp(p->h_name, name) == 0) 896 if (strcasecmp(p->h_name, name) == 0)
882 break; 897 break;
883 for (cp = p->h_aliases; *cp != 0; cp++) 898 for (cp = p->h_aliases; *cp != 0; cp++)
@@ -899,8 +914,7 @@ _gethtbyaddr(const void *addr, socklen_t len, int af)
899 914
900 _sethtent(0); 915 _sethtent(0);
901 while ((p = _gethtent())) 916 while ((p = _gethtent()))
902 if (p->h_addrtype == af && p->h_length == len && 917 if (p->h_addrtype == af && !bcmp(p->h_addr, addr, len))
903 !bcmp(p->h_addr, addr, len))
904 break; 918 break;
905 _endhtent(); 919 _endhtent();
906 return (p); 920 return (p);
@@ -1079,8 +1093,6 @@ map_v4v6_hostent(struct hostent *hp, char **bpp, char *ep)
1079struct hostent * 1093struct hostent *
1080gethostent(void) 1094gethostent(void)
1081{ 1095{
1082 host.h_addrtype = AF_UNSPEC;
1083 host.h_length = 0;
1084 return (_gethtent()); 1096 return (_gethtent());
1085} 1097}
1086 1098