History log of /netbsd-current/lib/libc/net/gethnamaddr.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.95 10-Aug-2023 mrg

avoid various use-after-free issues.

create a ptrdiff_t offset between the start of an allocation region and
some interesting pointer, so it can be adjusted with this offset after
realloc() returns.

found by GCC 12.


Revision tags: netbsd-10-base
# 1.94 19-Apr-2022 rillig

lib: remove CONSTCOND comment

Since 2021-01-31, lint doesn't need it anymore for the common pattern of
'do ... while (0)'.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.93 18-Nov-2020 is

Don't complain about additional DNAME records received when resolving A or
AAAA (like already done for SIG/KEY and CNAME).


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.92 22-Sep-2015 christos

branches: 1.92.8; 1.92.18;
- fix various leaks on error
- don't use the wrong error variable in switch
- always set the error return code
- return consistent errors when the input data cannot be handled.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.91 19-Jun-2014 christos

use fparseln() instead of abusing fgetln(), so that the last line that
might not have a terminating newline is processed.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.90 24-Jan-2014 christos

branches: 1.90.2;
CID 1163170, 1164171, resource leak
CID 1161172 double free


# 1.89 17-Jan-2014 drochner

fix memory allocation, and an off-by-one


# 1.88 17-Jan-2014 christos

the addition is handled in the alias.


# 1.87 17-Jan-2014 christos

Move more code into the macro, and fix the bug where realloc would cause
a dangling pointer and memory corruption.


# 1.86 16-Jan-2014 christos

Remove MAXALIASES limit


# 1.85 22-Dec-2013 christos

- don't clobber hp in the RES_USE_INET6 case
- increment naddrs in the yp case
- don't use __hostalias(), it is not thread-safe.


# 1.84 27-Aug-2013 christos

move the host file getbyname and getbyaddr functions to sethostent.c so
that they are in a separate file from the dns ones in order for libhack
to use them.


# 1.83 22-Aug-2013 christos

get rid of bogus + 1


# 1.82 19-Aug-2013 christos

fix gethostbyaddr prototype per TOG.


# 1.81 18-Aug-2013 christos

appease lint.


# 1.80 16-Aug-2013 christos

Add not advertised reentrant functions: {get,set,end}hostent_r,
gethostbyname{,2}_r, gethostbyaddr_r. Make getnameinfo(3) use
gethostbyaddr_r(3) so it is re-entrant (ahem __ypdomain). These
are not being advertised because there is a bunch of different
implementation of them that have a variety of type signatures.

If people want to follow someone's implementation, it is now easy.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.79 09-Sep-2012 christos

branches: 1.79.2;
implement no-check-names


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.78 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.77 15-Oct-2011 christos

branches: 1.77.2; 1.77.4;
close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.76 29-Aug-2010 christos

dprintf is claimed by posix.


Revision tags: matt-premerge-20091211
# 1.75 02-Oct-2009 wiz

Revert a -> an changes: Adding an 'n' follows pronunciation, not writing.


# 1.74 02-Oct-2009 cegger

fix grammar: a -> an


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE jym-xensuspend-nbase netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 jym-xensuspend-base netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 mjf-devfs2-base wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking cube-autoconf-base matt-armv6-base matt-mips64-base hpcarm-cleanup-base
# 1.73 27-Jan-2007 christos

branches: 1.73.18;
Appropriate versions are not supplied by bind anymore.


# 1.72 27-Jan-2007 christos

merge in resolver portion of bind-9.4.0-rc2


Revision tags: netbsd-4-base
# 1.71 15-Oct-2006 christos

branches: 1.71.2; 1.71.4;
fix incomplete initializers


Revision tags: abandoned-netbsd-4-base
# 1.70 22-Mar-2006 christos

Coverity CID 2279: Plug memory leak.


# 1.69 22-Mar-2006 christos

Coverity CID 2280: Plug memory leak.


# 1.68 24-Jan-2006 christos

PR/32616: Yves-Emmanuel JUTARD: Fix compilation with -DDEBUG


# 1.67 15-Sep-2005 tsarna

Rest of fix for PR#31184: getaddrinfo() now honors resolv.conf sortlist
directive for dns answers.

Also, unifdef the RESLVSORT (non-)option sillyness.

Reviewed by christos.


# 1.66 15-Sep-2005 tsarna

Re-enable resolv.conf sortlist support in gethostbyname().

Fixes first part of PR#31184. addrsort() was not exposed to the rest of
libc as it turns out not to be usable for getaddrinfo(), so a different
sorter will be implemented for that.


# 1.65 01-Jun-2005 lukem

appease gcc -Wuninitialized


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.64 23-Nov-2004 lukem

Fix gethostent(3) (which was reenabled in rev 1.63) so that it actually
works by allowing _gethtent() to treat host.h_addrtype==0 && host.h_length==0
as "any address family" when parsing.


# 1.63 17-Aug-2004 ginsbach

Restore gethostent() as a supported interface. Yes, it maybe obsolete
but it is specified by IEEE Std 1003.1, 2004 Edition (POSIX) and
the X/Open standards (Issue 6 and XNS 5.2).

* revert change removing gethostent() from gethostbyname(3) man page
* delete kruft from gethnamaddr.c leaving only gethostent() as a
wrapper around _gethtent().
* revert recent changes to <netdb.h>
+ restore gethostent() prototype
+ restore freehostent() prototype; handle similar to non-shipped
getipnodby*() prototypes
+ use correct XOPEN_SOURCE version (520 not 500) for freeaddrinfo()
prototype; interface specified by XNS5.2 not XNS5

Reviewd by <christos> and <drochner>.


# 1.62 21-Jul-2004 itojun

now that e.f.f.3.ip6.arpa is ready, we no longer need to query ip6.int


# 1.61 04-Jun-2004 ginsbach

Change remaining K&R style function definition to ANSI; Reviewd by <christos>.


# 1.60 23-May-2004 christos

centralize res_*init() calls in __res_get_state()


# 1.59 21-May-2004 christos

Finish bind9 resolver merge.


Revision tags: netbsd-2-0-base
# 1.58 11-Oct-2003 enami

branches: 1.58.2;
Back out rev. 1.56; `pointer points the byte just after the valid region'
is normal case. If the parser wants something more, there should be
another bounds check for it.


# 1.57 03-Oct-2003 itojun

paren around macro arg


# 1.56 03-Oct-2003 itojun

off-by-one. from millert@openbsd


# 1.55 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.


# 1.54 17-May-2003 itojun

bound copies


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.53 11-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


# 1.52 27-Aug-2002 itojun

allocate 64K recieve buffer for DNS responses.


# 1.51 22-Aug-2002 itojun

drop AAAA reply with IPv4 mapped address. sync w/kame
draft-itojun-v6ops-v4mapped-harmful-00.txt


# 1.50 16-Aug-2002 itojun

set h_errno properly if internal string manipulation fails.


# 1.49 16-Aug-2002 itojun

eliminate sprintf, use snprintf. check strlcat error.


# 1.48 29-Jul-2002 itojun

query ip6.arpa then ip6.int for IPv6 reverse lookup. follows RFC3152.


# 1.47 26-Jun-2002 itojun

correct DIAGASSERT


# 1.46 26-Jun-2002 itojun

avoid remote buffer overrun on hostbuf[]. From: Joost Pol <joost@pine.nl>

correct bad practice in the code - it uses two changing variables
to manage buffer (buf and buflen). we eliminate buflen and use
fixed point (ep) as the ending pointer.

this fix is critical.


# 1.45 26-Jun-2002 itojun

do not pass uninitialized variable to nsdispatch().


# 1.44 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


# 1.43 22-May-2002 itojun

be picky about string manipulation in reverse lookups


Revision tags: netbsd-1-6-base
# 1.42 18-May-2002 itojun

branches: 1.42.2;
style


# 1.41 17-May-2002 itojun

do not reverse-lookup scoped IPv6 address. it does not make sense as
there's no way to give scope identifier. sync w/kame


# 1.40 26-Apr-2001 kleink

Change the `len' arguemtn to gethostbyaddr(3) from int to socklen_t in
accordance with XNS5.2; fixes PR standards/12703.


# 1.39 20-Dec-2000 christos

branches: 1.39.2;
remove redundant declarations.


# 1.38 04-Oct-2000 sommerfeld

Varargsify dprintf to allow for format string checking


# 1.37 30-Jul-2000 itojun

on gethostby* with NIS backend, make a lookup against ipnodes.{byname,byaddr}
for non-IPv4 address. obeys solaris8 practice.

XXX does not support scoped address extension, as gethostby* are not
scope-aware. always use getaddrinfo/getnameinfo.
XXX it is not very useful at this moment, if you define multiple entries for
single hostname. see PR 10713 for detail.


# 1.36 30-Jul-2000 itojun

plug host_addrs overrun. rogue NIS server can transmit tons of lines,
effectively overrun host_addrs buffer.


# 1.35 07-Jul-2000 itohy

Passing "char" values to ctype(3) functions is problematic.
If an argument of a ctype function is outside "unsigned char"
and if it is not EOF, the behavior is undefined.

The isascii(3) is the sole exception of above and it was used to
be used to check a value was valid for other ctype functions in
ancient systems. On modern systems, the ctype functions take
all values of "unsigned char", and this check is obsolete and
even wrong for non-ASCII systems. However, we leave the isascii()
untouched for now, so as not to change the current behavior.


# 1.34 06-Jul-2000 christos

add CONSTCOND where appropriate


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 1.33 23-May-2000 tron

branches: 1.33.4;
Fix an alignment problem introduced by the patch for PR lib/8032.
Fixes PR lib/10048 by J.T. Conklin.


# 1.32 25-Apr-2000 itojun

sync with BIND 4.9.7. strict boundary checking.


# 1.31 02-Apr-2000 christos

Try to silence some of the lint warnings. Unfortunately we cannot fix
them all right now until we fix the ALIGN() macro to return u_long in
all the ports.


# 1.30 22-Jan-2000 mycroft

Delint.


# 1.29 22-Jan-2000 mycroft

Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


# 1.28 28-Dec-1999 assar

ignore KEY and SIG records when matching responses to the query. we
get those as extras from DNSsec-enabled name servers.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.27 24-Oct-1999 lukem

change default nsswitch.conf entry for `hosts' from:
hosts: dns files
to
hosts: files dns

this should speed things up a lot at boot if hostnames that are in
/etc/hosts are used for ifconfig, route, etc.


# 1.26 20-Sep-1999 lukem

branches: 1.26.2;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.


# 1.25 16-Sep-1999 lukem

* use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif


# 1.24 09-Aug-1999 itojun

do not make reverse query against IPv6 unspecified, or loopback addresses.

From: ume@mahoroba.org


# 1.23 19-Jul-1999 christos

- make sure that host_addr is suitably aligned
- add appropriate casts
- take out & in from array; it is meaningless


# 1.22 19-Jul-1999 tron

Make sure that "h_addr_list" pointers are longword aligned because some
broken applications depend on it. Fixes PR lib/8032 by David K Brownlee.


# 1.21 06-Jul-1999 itojun

fix name resolution problem when you have "hosts: files dns" on
/etc/nsswitch.conf.

This was because of two reasons:
- /etc/hosts lookup code damaged some of internal
state used by gethostbyname2().
- getaddrinfo() was not persistent enough against errors.

Sorry for the delay, and hope this fix all the following PRs
(I checked in my environment immitating those PRs and it worked for me)
PR: 7901, 7912, 7921


# 1.20 04-Jul-1999 itojun

check address family on getting entries from /etc/hosts.


# 1.19 01-Jul-1999 itojun

fix hardcoded T_A.
this fixes gethostbyname2(host, AF_INET6) to actually work.


# 1.18 02-Jun-1999 tron

As discussed on "tech-net@netbsd.org":
Enhance the file resolver to return all IP addresses of a host on a
call to gethostbyname().


# 1.17 04-May-1999 christos

Remove unused 'len' and the relevant gcc kludges.


# 1.16 03-May-1999 christos

Don't bother de-linting inside __GNUC__ ifdefs.


# 1.15 18-Apr-1999 lukem

specifically include stdarg/varargs.h


Revision tags: netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.14 20-Jan-1999 lukem

branches: 1.14.2;
minor knf; don't exceed 80 columns ;)


# 1.13 20-Jan-1999 christos

add ARGSUSED


# 1.12 19-Jan-1999 lukem

constify ns_dtab defs


# 1.11 19-Jan-1999 lukem

convert to new nsdispatch(3). lookup defaults back to "dns files"


# 1.10 18-Jan-1999 lukem

before each call to nsdispatch(), set h_errno to NETDB_INTERNAL, and only
change to NETDB_SUCCESS if nsdispatch() returns NS_SUCCESS. it is up to the
internal methods to change h_errno from NETDB_INTERNAL to a more appropriate
value when an error is detected.


# 1.9 16-Jan-1999 lukem

pull nsswitch up to main branch
convert getnetby*() to nsswitch (from resolv.conf lookup)


# 1.8 13-Nov-1998 christos

delint


# 1.7 15-Oct-1998 kleink

branches: 1.7.2;
(bcmp(), bcopy(), bzero()) -> (memcmp(), memcpy(), memset())


# 1.6 14-Oct-1998 kleink

Since these files are shared with parts of the BIND-4 userland (outside libc),
do the internal symbol renaming dance only if inside the libc build environment.


# 1.5 13-Oct-1998 kleink

Need internal names for gethostby{addr,name}().


# 1.4 06-Jan-1998 perry

$Id: -> Id: (to make hunting down other bad Ids easier).


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.3 31-Jul-1997 thorpej

Bring over changes where were mistakenly committed to gethostnamadr.c:

date: 1997/07/21 14:07:54; author: jtc; state: Exp; lines: +3 -2
If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.2 20-Jul-1997 mrg

merge bind 4.9.6 resolver. still need to fix <resolv.h>


# 1.1 20-Jul-1997 mrg

branches: 1.1.1;
Initial revision


# 1.94 19-Apr-2022 rillig

lib: remove CONSTCOND comment

Since 2021-01-31, lint doesn't need it anymore for the common pattern of
'do ... while (0)'.


Revision tags: cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 cjep_staticlib_x-base
# 1.93 18-Nov-2020 is

Don't complain about additional DNAME records received when resolving A or
AAAA (like already done for SIG/KEY and CNAME).


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.92 22-Sep-2015 christos

branches: 1.92.8; 1.92.18;
- fix various leaks on error
- don't use the wrong error variable in switch
- always set the error return code
- return consistent errors when the input data cannot be handled.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.91 19-Jun-2014 christos

use fparseln() instead of abusing fgetln(), so that the last line that
might not have a terminating newline is processed.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.90 24-Jan-2014 christos

branches: 1.90.2;
CID 1163170, 1164171, resource leak
CID 1161172 double free


# 1.89 17-Jan-2014 drochner

fix memory allocation, and an off-by-one


# 1.88 17-Jan-2014 christos

the addition is handled in the alias.


# 1.87 17-Jan-2014 christos

Move more code into the macro, and fix the bug where realloc would cause
a dangling pointer and memory corruption.


# 1.86 16-Jan-2014 christos

Remove MAXALIASES limit


# 1.85 22-Dec-2013 christos

- don't clobber hp in the RES_USE_INET6 case
- increment naddrs in the yp case
- don't use __hostalias(), it is not thread-safe.


# 1.84 27-Aug-2013 christos

move the host file getbyname and getbyaddr functions to sethostent.c so
that they are in a separate file from the dns ones in order for libhack
to use them.


# 1.83 22-Aug-2013 christos

get rid of bogus + 1


# 1.82 19-Aug-2013 christos

fix gethostbyaddr prototype per TOG.


# 1.81 18-Aug-2013 christos

appease lint.


# 1.80 16-Aug-2013 christos

Add not advertised reentrant functions: {get,set,end}hostent_r,
gethostbyname{,2}_r, gethostbyaddr_r. Make getnameinfo(3) use
gethostbyaddr_r(3) so it is re-entrant (ahem __ypdomain). These
are not being advertised because there is a bunch of different
implementation of them that have a variety of type signatures.

If people want to follow someone's implementation, it is now easy.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.79 09-Sep-2012 christos

branches: 1.79.2;
implement no-check-names


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.78 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.77 15-Oct-2011 christos

branches: 1.77.2; 1.77.4;
close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.76 29-Aug-2010 christos

dprintf is claimed by posix.


Revision tags: matt-premerge-20091211
# 1.75 02-Oct-2009 wiz

Revert a -> an changes: Adding an 'n' follows pronunciation, not writing.


# 1.74 02-Oct-2009 cegger

fix grammar: a -> an


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE jym-xensuspend-nbase netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 jym-xensuspend-base netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 mjf-devfs2-base wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking cube-autoconf-base matt-armv6-base matt-mips64-base hpcarm-cleanup-base
# 1.73 27-Jan-2007 christos

branches: 1.73.18;
Appropriate versions are not supplied by bind anymore.


# 1.72 27-Jan-2007 christos

merge in resolver portion of bind-9.4.0-rc2


Revision tags: netbsd-4-base
# 1.71 15-Oct-2006 christos

branches: 1.71.2; 1.71.4;
fix incomplete initializers


Revision tags: abandoned-netbsd-4-base
# 1.70 22-Mar-2006 christos

Coverity CID 2279: Plug memory leak.


# 1.69 22-Mar-2006 christos

Coverity CID 2280: Plug memory leak.


# 1.68 24-Jan-2006 christos

PR/32616: Yves-Emmanuel JUTARD: Fix compilation with -DDEBUG


# 1.67 15-Sep-2005 tsarna

Rest of fix for PR#31184: getaddrinfo() now honors resolv.conf sortlist
directive for dns answers.

Also, unifdef the RESLVSORT (non-)option sillyness.

Reviewed by christos.


# 1.66 15-Sep-2005 tsarna

Re-enable resolv.conf sortlist support in gethostbyname().

Fixes first part of PR#31184. addrsort() was not exposed to the rest of
libc as it turns out not to be usable for getaddrinfo(), so a different
sorter will be implemented for that.


# 1.65 01-Jun-2005 lukem

appease gcc -Wuninitialized


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.64 23-Nov-2004 lukem

Fix gethostent(3) (which was reenabled in rev 1.63) so that it actually
works by allowing _gethtent() to treat host.h_addrtype==0 && host.h_length==0
as "any address family" when parsing.


# 1.63 17-Aug-2004 ginsbach

Restore gethostent() as a supported interface. Yes, it maybe obsolete
but it is specified by IEEE Std 1003.1, 2004 Edition (POSIX) and
the X/Open standards (Issue 6 and XNS 5.2).

* revert change removing gethostent() from gethostbyname(3) man page
* delete kruft from gethnamaddr.c leaving only gethostent() as a
wrapper around _gethtent().
* revert recent changes to <netdb.h>
+ restore gethostent() prototype
+ restore freehostent() prototype; handle similar to non-shipped
getipnodby*() prototypes
+ use correct XOPEN_SOURCE version (520 not 500) for freeaddrinfo()
prototype; interface specified by XNS5.2 not XNS5

Reviewd by <christos> and <drochner>.


# 1.62 21-Jul-2004 itojun

now that e.f.f.3.ip6.arpa is ready, we no longer need to query ip6.int


# 1.61 04-Jun-2004 ginsbach

Change remaining K&R style function definition to ANSI; Reviewd by <christos>.


# 1.60 23-May-2004 christos

centralize res_*init() calls in __res_get_state()


# 1.59 21-May-2004 christos

Finish bind9 resolver merge.


Revision tags: netbsd-2-0-base
# 1.58 11-Oct-2003 enami

branches: 1.58.2;
Back out rev. 1.56; `pointer points the byte just after the valid region'
is normal case. If the parser wants something more, there should be
another bounds check for it.


# 1.57 03-Oct-2003 itojun

paren around macro arg


# 1.56 03-Oct-2003 itojun

off-by-one. from millert@openbsd


# 1.55 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.


# 1.54 17-May-2003 itojun

bound copies


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.53 11-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


# 1.52 27-Aug-2002 itojun

allocate 64K recieve buffer for DNS responses.


# 1.51 22-Aug-2002 itojun

drop AAAA reply with IPv4 mapped address. sync w/kame
draft-itojun-v6ops-v4mapped-harmful-00.txt


# 1.50 16-Aug-2002 itojun

set h_errno properly if internal string manipulation fails.


# 1.49 16-Aug-2002 itojun

eliminate sprintf, use snprintf. check strlcat error.


# 1.48 29-Jul-2002 itojun

query ip6.arpa then ip6.int for IPv6 reverse lookup. follows RFC3152.


# 1.47 26-Jun-2002 itojun

correct DIAGASSERT


# 1.46 26-Jun-2002 itojun

avoid remote buffer overrun on hostbuf[]. From: Joost Pol <joost@pine.nl>

correct bad practice in the code - it uses two changing variables
to manage buffer (buf and buflen). we eliminate buflen and use
fixed point (ep) as the ending pointer.

this fix is critical.


# 1.45 26-Jun-2002 itojun

do not pass uninitialized variable to nsdispatch().


# 1.44 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


# 1.43 22-May-2002 itojun

be picky about string manipulation in reverse lookups


Revision tags: netbsd-1-6-base
# 1.42 18-May-2002 itojun

branches: 1.42.2;
style


# 1.41 17-May-2002 itojun

do not reverse-lookup scoped IPv6 address. it does not make sense as
there's no way to give scope identifier. sync w/kame


# 1.40 26-Apr-2001 kleink

Change the `len' arguemtn to gethostbyaddr(3) from int to socklen_t in
accordance with XNS5.2; fixes PR standards/12703.


# 1.39 20-Dec-2000 christos

branches: 1.39.2;
remove redundant declarations.


# 1.38 04-Oct-2000 sommerfeld

Varargsify dprintf to allow for format string checking


# 1.37 30-Jul-2000 itojun

on gethostby* with NIS backend, make a lookup against ipnodes.{byname,byaddr}
for non-IPv4 address. obeys solaris8 practice.

XXX does not support scoped address extension, as gethostby* are not
scope-aware. always use getaddrinfo/getnameinfo.
XXX it is not very useful at this moment, if you define multiple entries for
single hostname. see PR 10713 for detail.


# 1.36 30-Jul-2000 itojun

plug host_addrs overrun. rogue NIS server can transmit tons of lines,
effectively overrun host_addrs buffer.


# 1.35 07-Jul-2000 itohy

Passing "char" values to ctype(3) functions is problematic.
If an argument of a ctype function is outside "unsigned char"
and if it is not EOF, the behavior is undefined.

The isascii(3) is the sole exception of above and it was used to
be used to check a value was valid for other ctype functions in
ancient systems. On modern systems, the ctype functions take
all values of "unsigned char", and this check is obsolete and
even wrong for non-ASCII systems. However, we leave the isascii()
untouched for now, so as not to change the current behavior.


# 1.34 06-Jul-2000 christos

add CONSTCOND where appropriate


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 1.33 23-May-2000 tron

branches: 1.33.4;
Fix an alignment problem introduced by the patch for PR lib/8032.
Fixes PR lib/10048 by J.T. Conklin.


# 1.32 25-Apr-2000 itojun

sync with BIND 4.9.7. strict boundary checking.


# 1.31 02-Apr-2000 christos

Try to silence some of the lint warnings. Unfortunately we cannot fix
them all right now until we fix the ALIGN() macro to return u_long in
all the ports.


# 1.30 22-Jan-2000 mycroft

Delint.


# 1.29 22-Jan-2000 mycroft

Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


# 1.28 28-Dec-1999 assar

ignore KEY and SIG records when matching responses to the query. we
get those as extras from DNSsec-enabled name servers.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.27 24-Oct-1999 lukem

change default nsswitch.conf entry for `hosts' from:
hosts: dns files
to
hosts: files dns

this should speed things up a lot at boot if hostnames that are in
/etc/hosts are used for ifconfig, route, etc.


# 1.26 20-Sep-1999 lukem

branches: 1.26.2;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.


# 1.25 16-Sep-1999 lukem

* use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif


# 1.24 09-Aug-1999 itojun

do not make reverse query against IPv6 unspecified, or loopback addresses.

From: ume@mahoroba.org


# 1.23 19-Jul-1999 christos

- make sure that host_addr is suitably aligned
- add appropriate casts
- take out & in from array; it is meaningless


# 1.22 19-Jul-1999 tron

Make sure that "h_addr_list" pointers are longword aligned because some
broken applications depend on it. Fixes PR lib/8032 by David K Brownlee.


# 1.21 06-Jul-1999 itojun

fix name resolution problem when you have "hosts: files dns" on
/etc/nsswitch.conf.

This was because of two reasons:
- /etc/hosts lookup code damaged some of internal
state used by gethostbyname2().
- getaddrinfo() was not persistent enough against errors.

Sorry for the delay, and hope this fix all the following PRs
(I checked in my environment immitating those PRs and it worked for me)
PR: 7901, 7912, 7921


# 1.20 04-Jul-1999 itojun

check address family on getting entries from /etc/hosts.


# 1.19 01-Jul-1999 itojun

fix hardcoded T_A.
this fixes gethostbyname2(host, AF_INET6) to actually work.


# 1.18 02-Jun-1999 tron

As discussed on "tech-net@netbsd.org":
Enhance the file resolver to return all IP addresses of a host on a
call to gethostbyname().


# 1.17 04-May-1999 christos

Remove unused 'len' and the relevant gcc kludges.


# 1.16 03-May-1999 christos

Don't bother de-linting inside __GNUC__ ifdefs.


# 1.15 18-Apr-1999 lukem

specifically include stdarg/varargs.h


Revision tags: netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.14 20-Jan-1999 lukem

branches: 1.14.2;
minor knf; don't exceed 80 columns ;)


# 1.13 20-Jan-1999 christos

add ARGSUSED


# 1.12 19-Jan-1999 lukem

constify ns_dtab defs


# 1.11 19-Jan-1999 lukem

convert to new nsdispatch(3). lookup defaults back to "dns files"


# 1.10 18-Jan-1999 lukem

before each call to nsdispatch(), set h_errno to NETDB_INTERNAL, and only
change to NETDB_SUCCESS if nsdispatch() returns NS_SUCCESS. it is up to the
internal methods to change h_errno from NETDB_INTERNAL to a more appropriate
value when an error is detected.


# 1.9 16-Jan-1999 lukem

pull nsswitch up to main branch
convert getnetby*() to nsswitch (from resolv.conf lookup)


# 1.8 13-Nov-1998 christos

delint


# 1.7 15-Oct-1998 kleink

branches: 1.7.2;
(bcmp(), bcopy(), bzero()) -> (memcmp(), memcpy(), memset())


# 1.6 14-Oct-1998 kleink

Since these files are shared with parts of the BIND-4 userland (outside libc),
do the internal symbol renaming dance only if inside the libc build environment.


# 1.5 13-Oct-1998 kleink

Need internal names for gethostby{addr,name}().


# 1.4 06-Jan-1998 perry

$Id: -> Id: (to make hunting down other bad Ids easier).


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.3 31-Jul-1997 thorpej

Bring over changes where were mistakenly committed to gethostnamadr.c:

date: 1997/07/21 14:07:54; author: jtc; state: Exp; lines: +3 -2
If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.2 20-Jul-1997 mrg

merge bind 4.9.6 resolver. still need to fix <resolv.h>


# 1.1 20-Jul-1997 mrg

branches: 1.1.1;
Initial revision


# 1.93 18-Nov-2020 is

Don't complain about additional DNAME records received when resolving A or
AAAA (like already done for SIG/KEY and CNAME).


Revision tags: netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-8-2-RELEASE netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 netbsd-8-1-RELEASE netbsd-8-1-RC1 pgoyette-compat-merge-20190127 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126 pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 netbsd-8-0-RELEASE phil-wifi-base pgoyette-compat-0625 netbsd-8-0-RC2 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 netbsd-8-0-RC1 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 bouyer-socketcan-base pgoyette-localcount-20170107 pgoyette-localcount-20161104 localcount-20160914 pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base
# 1.92 22-Sep-2015 christos

- fix various leaks on error
- don't use the wrong error variable in switch
- always set the error return code
- return consistent errors when the input data cannot be handled.


Revision tags: netbsd-7-2-RELEASE netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 netbsd-7-1-RC1 netbsd-7-0-2-RELEASE netbsd-7-nhusb-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base tls-earlyentropy-base tls-maxphys-base
# 1.91 19-Jun-2014 christos

use fparseln() instead of abusing fgetln(), so that the last line that
might not have a terminating newline is processed.


Revision tags: yamt-pagecache-base9 riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.90 24-Jan-2014 christos

branches: 1.90.2;
CID 1163170, 1164171, resource leak
CID 1161172 double free


# 1.89 17-Jan-2014 drochner

fix memory allocation, and an off-by-one


# 1.88 17-Jan-2014 christos

the addition is handled in the alias.


# 1.87 17-Jan-2014 christos

Move more code into the macro, and fix the bug where realloc would cause
a dangling pointer and memory corruption.


# 1.86 16-Jan-2014 christos

Remove MAXALIASES limit


# 1.85 22-Dec-2013 christos

- don't clobber hp in the RES_USE_INET6 case
- increment naddrs in the yp case
- don't use __hostalias(), it is not thread-safe.


# 1.84 27-Aug-2013 christos

move the host file getbyname and getbyaddr functions to sethostent.c so
that they are in a separate file from the dns ones in order for libhack
to use them.


# 1.83 22-Aug-2013 christos

get rid of bogus + 1


# 1.82 19-Aug-2013 christos

fix gethostbyaddr prototype per TOG.


# 1.81 18-Aug-2013 christos

appease lint.


# 1.80 16-Aug-2013 christos

Add not advertised reentrant functions: {get,set,end}hostent_r,
gethostbyname{,2}_r, gethostbyaddr_r. Make getnameinfo(3) use
gethostbyaddr_r(3) so it is re-entrant (ahem __ypdomain). These
are not being advertised because there is a bunch of different
implementation of them that have a variety of type signatures.

If people want to follow someone's implementation, it is now easy.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base yamt-pagecache-base8 yamt-pagecache-base7 yamt-pagecache-base6
# 1.79 09-Sep-2012 christos

branches: 1.79.2;
implement no-check-names


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.78 13-Mar-2012 christos

PR/45989: Martin Husemann: lint invocation does include -w only on i386

- turn lint -w for all the platforms after fixing the lint warnings.
- add _DIAGASSERTS() for casts that would assign values to types that
would not fit.
- change types, add casts
- change into ansii prototypes
- turn on _DIAGNOSTIC for libc (during current, to be eliminated for release
builds)

approved by core@


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base
# 1.77 15-Oct-2011 christos

branches: 1.77.2; 1.77.4;
close on exec fixes:
- open + fcntl -> open O_CLOEXEC
- configuration database file descriptors that can stay open are now opened
fopen(db, "re")


Revision tags: cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231
# 1.76 29-Aug-2010 christos

dprintf is claimed by posix.


Revision tags: matt-premerge-20091211
# 1.75 02-Oct-2009 wiz

Revert a -> an changes: Adding an 'n' follows pronunciation, not writing.


# 1.74 02-Oct-2009 cegger

fix grammar: a -> an


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE jym-xensuspend-nbase netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 jym-xensuspend-base netbsd-5-0-RC1 christos-time_t-nbase christos-time_t-base netbsd-5-base matt-mips64-base2 mjf-devfs2-base wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking cube-autoconf-base matt-armv6-base matt-mips64-base hpcarm-cleanup-base
# 1.73 27-Jan-2007 christos

branches: 1.73.18;
Appropriate versions are not supplied by bind anymore.


# 1.72 27-Jan-2007 christos

merge in resolver portion of bind-9.4.0-rc2


Revision tags: netbsd-4-base
# 1.71 15-Oct-2006 christos

branches: 1.71.2; 1.71.4;
fix incomplete initializers


Revision tags: abandoned-netbsd-4-base
# 1.70 22-Mar-2006 christos

Coverity CID 2279: Plug memory leak.


# 1.69 22-Mar-2006 christos

Coverity CID 2280: Plug memory leak.


# 1.68 24-Jan-2006 christos

PR/32616: Yves-Emmanuel JUTARD: Fix compilation with -DDEBUG


# 1.67 15-Sep-2005 tsarna

Rest of fix for PR#31184: getaddrinfo() now honors resolv.conf sortlist
directive for dns answers.

Also, unifdef the RESLVSORT (non-)option sillyness.

Reviewed by christos.


# 1.66 15-Sep-2005 tsarna

Re-enable resolv.conf sortlist support in gethostbyname().

Fixes first part of PR#31184. addrsort() was not exposed to the rest of
libc as it turns out not to be usable for getaddrinfo(), so a different
sorter will be implemented for that.


# 1.65 01-Jun-2005 lukem

appease gcc -Wuninitialized


Revision tags: netbsd-3-1-1-RELEASE netbsd-3-0-3-RELEASE netbsd-3-1-RELEASE netbsd-3-0-2-RELEASE netbsd-3-1-RC4 netbsd-3-1-RC3 netbsd-3-1-RC2 netbsd-3-1-RC1 netbsd-3-0-1-RELEASE netbsd-3-0-RELEASE netbsd-3-0-RC6 netbsd-3-0-RC5 netbsd-3-0-RC4 netbsd-3-0-RC3 netbsd-3-0-RC2 netbsd-3-0-RC1 netbsd-3-base
# 1.64 23-Nov-2004 lukem

Fix gethostent(3) (which was reenabled in rev 1.63) so that it actually
works by allowing _gethtent() to treat host.h_addrtype==0 && host.h_length==0
as "any address family" when parsing.


# 1.63 17-Aug-2004 ginsbach

Restore gethostent() as a supported interface. Yes, it maybe obsolete
but it is specified by IEEE Std 1003.1, 2004 Edition (POSIX) and
the X/Open standards (Issue 6 and XNS 5.2).

* revert change removing gethostent() from gethostbyname(3) man page
* delete kruft from gethnamaddr.c leaving only gethostent() as a
wrapper around _gethtent().
* revert recent changes to <netdb.h>
+ restore gethostent() prototype
+ restore freehostent() prototype; handle similar to non-shipped
getipnodby*() prototypes
+ use correct XOPEN_SOURCE version (520 not 500) for freeaddrinfo()
prototype; interface specified by XNS5.2 not XNS5

Reviewd by <christos> and <drochner>.


# 1.62 21-Jul-2004 itojun

now that e.f.f.3.ip6.arpa is ready, we no longer need to query ip6.int


# 1.61 04-Jun-2004 ginsbach

Change remaining K&R style function definition to ANSI; Reviewd by <christos>.


# 1.60 23-May-2004 christos

centralize res_*init() calls in __res_get_state()


# 1.59 21-May-2004 christos

Finish bind9 resolver merge.


Revision tags: netbsd-2-0-base
# 1.58 11-Oct-2003 enami

branches: 1.58.2;
Back out rev. 1.56; `pointer points the byte just after the valid region'
is normal case. If the parser wants something more, there should be
another bounds check for it.


# 1.57 03-Oct-2003 itojun

paren around macro arg


# 1.56 03-Oct-2003 itojun

off-by-one. from millert@openbsd


# 1.55 07-Aug-2003 agc

Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22280, verified by myself.


# 1.54 17-May-2003 itojun

bound copies


Revision tags: nathanw_sa_before_merge fvdl_fs64_base nathanw_sa_base
# 1.53 11-Nov-2002 thorpej

Fix signed/unsigned comparison warnings.


# 1.52 27-Aug-2002 itojun

allocate 64K recieve buffer for DNS responses.


# 1.51 22-Aug-2002 itojun

drop AAAA reply with IPv4 mapped address. sync w/kame
draft-itojun-v6ops-v4mapped-harmful-00.txt


# 1.50 16-Aug-2002 itojun

set h_errno properly if internal string manipulation fails.


# 1.49 16-Aug-2002 itojun

eliminate sprintf, use snprintf. check strlcat error.


# 1.48 29-Jul-2002 itojun

query ip6.arpa then ip6.int for IPv6 reverse lookup. follows RFC3152.


# 1.47 26-Jun-2002 itojun

correct DIAGASSERT


# 1.46 26-Jun-2002 itojun

avoid remote buffer overrun on hostbuf[]. From: Joost Pol <joost@pine.nl>

correct bad practice in the code - it uses two changing variables
to manage buffer (buf and buflen). we eliminate buflen and use
fixed point (ep) as the ending pointer.

this fix is critical.


# 1.45 26-Jun-2002 itojun

do not pass uninitialized variable to nsdispatch().


# 1.44 26-May-2002 wiz

__STDC__ is always defined on NetBSD.


# 1.43 22-May-2002 itojun

be picky about string manipulation in reverse lookups


Revision tags: netbsd-1-6-base
# 1.42 18-May-2002 itojun

branches: 1.42.2;
style


# 1.41 17-May-2002 itojun

do not reverse-lookup scoped IPv6 address. it does not make sense as
there's no way to give scope identifier. sync w/kame


# 1.40 26-Apr-2001 kleink

Change the `len' arguemtn to gethostbyaddr(3) from int to socklen_t in
accordance with XNS5.2; fixes PR standards/12703.


# 1.39 20-Dec-2000 christos

branches: 1.39.2;
remove redundant declarations.


# 1.38 04-Oct-2000 sommerfeld

Varargsify dprintf to allow for format string checking


# 1.37 30-Jul-2000 itojun

on gethostby* with NIS backend, make a lookup against ipnodes.{byname,byaddr}
for non-IPv4 address. obeys solaris8 practice.

XXX does not support scoped address extension, as gethostby* are not
scope-aware. always use getaddrinfo/getnameinfo.
XXX it is not very useful at this moment, if you define multiple entries for
single hostname. see PR 10713 for detail.


# 1.36 30-Jul-2000 itojun

plug host_addrs overrun. rogue NIS server can transmit tons of lines,
effectively overrun host_addrs buffer.


# 1.35 07-Jul-2000 itohy

Passing "char" values to ctype(3) functions is problematic.
If an argument of a ctype function is outside "unsigned char"
and if it is not EOF, the behavior is undefined.

The isascii(3) is the sole exception of above and it was used to
be used to check a value was valid for other ctype functions in
ancient systems. On modern systems, the ctype functions take
all values of "unsigned char", and this check is obsolete and
even wrong for non-ASCII systems. However, we leave the isascii()
untouched for now, so as not to change the current behavior.


# 1.34 06-Jul-2000 christos

add CONSTCOND where appropriate


Revision tags: netbsd-1-5-base minoura-xpg4dl-base
# 1.33 23-May-2000 tron

branches: 1.33.4;
Fix an alignment problem introduced by the patch for PR lib/8032.
Fixes PR lib/10048 by J.T. Conklin.


# 1.32 25-Apr-2000 itojun

sync with BIND 4.9.7. strict boundary checking.


# 1.31 02-Apr-2000 christos

Try to silence some of the lint warnings. Unfortunately we cannot fix
them all right now until we fix the ALIGN() macro to return u_long in
all the ports.


# 1.30 22-Jan-2000 mycroft

Delint.


# 1.29 22-Jan-2000 mycroft

Delint.
Remove trailing ; from uses of __weak_alias(). The macro inserts this if
needed.


# 1.28 28-Dec-1999 assar

ignore KEY and SIG records when matching responses to the query. we
get those as extras from DNSsec-enabled name servers.


Revision tags: wrstuden-devbsize-19991221 wrstuden-devbsize-base comdex-fall-1999-base
# 1.27 24-Oct-1999 lukem

change default nsswitch.conf entry for `hosts' from:
hosts: dns files
to
hosts: files dns

this should speed things up a lot at boot if hostnames that are in
/etc/hosts are used for ifconfig, route, etc.


# 1.26 20-Sep-1999 lukem

branches: 1.26.2;
back out the #ifdef _DIAGNOSTIC argument checks; too many people complained.
_DIAGASSERT() is still retained.


# 1.25 16-Sep-1999 lukem

* use _DIAGASSERT() to check pointer arguments against NULL and file
descriptors against -1 (as appropriate).
* add actual checks which to detect stuff that would trigger_DIAGASSERT(),
and attempt to return a sane error condition.
* knf some code
* remove some `register' decls.

the first two items result in the addition of code similar to the
following in various functions:

_DIAGASSERT(path != NULL)
#ifdef _DIAGNOSTIC
if (path == NULL) {
errno = EFAULT;
return (-1);
}
#endif


# 1.24 09-Aug-1999 itojun

do not make reverse query against IPv6 unspecified, or loopback addresses.

From: ume@mahoroba.org


# 1.23 19-Jul-1999 christos

- make sure that host_addr is suitably aligned
- add appropriate casts
- take out & in from array; it is meaningless


# 1.22 19-Jul-1999 tron

Make sure that "h_addr_list" pointers are longword aligned because some
broken applications depend on it. Fixes PR lib/8032 by David K Brownlee.


# 1.21 06-Jul-1999 itojun

fix name resolution problem when you have "hosts: files dns" on
/etc/nsswitch.conf.

This was because of two reasons:
- /etc/hosts lookup code damaged some of internal
state used by gethostbyname2().
- getaddrinfo() was not persistent enough against errors.

Sorry for the delay, and hope this fix all the following PRs
(I checked in my environment immitating those PRs and it worked for me)
PR: 7901, 7912, 7921


# 1.20 04-Jul-1999 itojun

check address family on getting entries from /etc/hosts.


# 1.19 01-Jul-1999 itojun

fix hardcoded T_A.
this fixes gethostbyname2(host, AF_INET6) to actually work.


# 1.18 02-Jun-1999 tron

As discussed on "tech-net@netbsd.org":
Enhance the file resolver to return all IP addresses of a host on a
call to gethostbyname().


# 1.17 04-May-1999 christos

Remove unused 'len' and the relevant gcc kludges.


# 1.16 03-May-1999 christos

Don't bother de-linting inside __GNUC__ ifdefs.


# 1.15 18-Apr-1999 lukem

specifically include stdarg/varargs.h


Revision tags: netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.14 20-Jan-1999 lukem

branches: 1.14.2;
minor knf; don't exceed 80 columns ;)


# 1.13 20-Jan-1999 christos

add ARGSUSED


# 1.12 19-Jan-1999 lukem

constify ns_dtab defs


# 1.11 19-Jan-1999 lukem

convert to new nsdispatch(3). lookup defaults back to "dns files"


# 1.10 18-Jan-1999 lukem

before each call to nsdispatch(), set h_errno to NETDB_INTERNAL, and only
change to NETDB_SUCCESS if nsdispatch() returns NS_SUCCESS. it is up to the
internal methods to change h_errno from NETDB_INTERNAL to a more appropriate
value when an error is detected.


# 1.9 16-Jan-1999 lukem

pull nsswitch up to main branch
convert getnetby*() to nsswitch (from resolv.conf lookup)


# 1.8 13-Nov-1998 christos

delint


# 1.7 15-Oct-1998 kleink

branches: 1.7.2;
(bcmp(), bcopy(), bzero()) -> (memcmp(), memcpy(), memset())


# 1.6 14-Oct-1998 kleink

Since these files are shared with parts of the BIND-4 userland (outside libc),
do the internal symbol renaming dance only if inside the libc build environment.


# 1.5 13-Oct-1998 kleink

Need internal names for gethostby{addr,name}().


# 1.4 06-Jan-1998 perry

$Id: -> Id: (to make hunting down other bad Ids easier).


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 1.3 31-Jul-1997 thorpej

Bring over changes where were mistakenly committed to gethostnamadr.c:

date: 1997/07/21 14:07:54; author: jtc; state: Exp; lines: +3 -2
If port provides __weak_alias(), provide an Standard C and POSIX pure
identifier namespace by renaming non standard functions and variables
such that they have a leading underscore. The library will use those
names internally. Weak aliases are used to provide the original names
to the API.

This is only the first part of this change. It is most of the functions
which are implemented in C for all NetBSD ports. Subsequent changes are
to add the same support to the remaining C files, to assembly files, and
to the automagically generated assembly source used for system calls.
When all of the above is done, ports with weak alias support should add
a definition for __weak_alias to <sys/cdefs.h>.


# 1.2 20-Jul-1997 mrg

merge bind 4.9.6 resolver. still need to fix <resolv.h>


# 1.1 20-Jul-1997 mrg

branches: 1.1.1;
Initial revision