summaryrefslogtreecommitdiff
path: root/libc/inet/resolv.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-02-23 01:08:27 +0000
committerEric Andersen <andersen@codepoet.org>2001-02-23 01:08:27 +0000
commit671d0dad5ce04fd243e8e3bda49f7e6be0ac1f94 (patch)
tree79f4fba4202447a212fdd62d4eef9a4066f22c80 /libc/inet/resolv.c
parent1317d65dbecb98e9c540fa783a7ef88a9bffb94c (diff)
Fix two bugs. First, gethostbyname was doing dns queries when given an IP
address. Secondly, when doing reverse dns lookups, it was appending the domain, even if a domain was already attached. -Erik
Diffstat (limited to 'libc/inet/resolv.c')
-rw-r--r--libc/inet/resolv.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index 900783fbf..30e555db0 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -497,7 +497,7 @@ int dns_lookup(const char *name, int type, int nscount, const char **nsip,
goto fail;
strncpy(lookup,name,MAXDNAME);
- if (variant < searchdomains)
+ if (variant < searchdomains && strchr(lookup, '.') == NULL)
{
strncat(lookup,".", MAXDNAME);
strncat(lookup,searchdomain[variant], MAXDNAME);
@@ -851,14 +851,27 @@ struct hostent *gethostbyname(const char *name)
if (!name)
return 0;
-
+
memset(&h, 0, sizeof(h));
addr_list[0] = &in;
addr_list[1] = 0;
-
+
strcpy(namebuf, name);
+ /* First check if this is already an address */
+ if (inet_aton(name, &in)) {
+ i = inet_aton( name, &in);
+
+ if (i >= 0) {
+ h.h_name = namebuf;
+ h.h_addrtype = AF_INET;
+ h.h_length = sizeof(in);
+ h.h_addr_list = (char **) addr_list;
+ return &h;
+ }
+ }
+
for (;;) {
i = dns_lookup(namebuf, 1, nameservers, nameserver, &packet, &a);