Re: gethostbyaddr(3) fails when DNS PTR record has a wildcard
[email protected] (Christos Zoulas)
| Newsgroups | gmane.os.netbsd.help |
|---|---|
| Message-ID | <[email protected]> |
In article <[email protected]>, Jeremy C. Reed <[email protected]> wrote: >I saw this DNS entry: > > 10.7.18.64.in-addr.arpa. 22018 IN PTR *.s8a1.psmtp.com. > >Which resolves with dig and host and nslookup, for example: > > $ host 64.18.7.10 > 10.7.18.64.in-addr.arpa domain name pointer *.s8a1.psmtp.com. > > >But gethostbyaddr(3) fails for that and h_errno is "3" which is: > >#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ > >Or: > > NO_RECOVERY Some unexpected server failure was encountered. This is > a non-recoverable error. > >And hstrerror(h_errno) has "Unknown server error". > >ktrace shows: > > 19145 1 gethost CALL >recvfrom(3,0x805b000,0x10000,0,0xbfbfdd70,0xbfbfde3c) > 19145 1 gethost GIO fd 3 read 71 bytes > "\M^[\M-Y\M^A\M^@\0\^A\0\^A\0\0\0\0\^B10\^A7\^B18\^B64\ain-addr\^Darpa\ > \0\0\f\0\^A\M-@\f\0\f\0\^A\0\0@\M-:\0\^R\^A*\^Ds8a1\^Epsmtp\^Ccom\0" > > >This is NetBSD 3.99.24. > >I am trying to look through /usr/src/lib/libc/net/gethnamaddr.c to see why >this is happening. Any clues? > >But has anyone else seen this type of PTR value? Is it okay? Is >gethostbyaddr(3) broken? (Or maybe I am using it wrong.) > > >By the way, I was testing this with my pkgsrc/net/gethost tool. The record: 10.7.18.64.in-addr.arpa domain name pointer *.s8a1.psmtp.com. is an RFC/1034 wildcard record. gethostbyaddr() uses res_hnok() to check for the validity of the returned hostname which only accepts valid hostnames, not wildcarded ones like res_ownok() accepts. I think this is by design. Anyway why are you using the antiquated gethostbyaddr() call instead of getnameinfo()? christos