CVSROOT:        /cvs
Module name:    src
Changes by:     [email protected]   2026/11/10 15:44:58

Modified files:
        lib/libc/asr   : Tag: OPENBSD_7_9 asr.c asr_utils.c 
                         getaddrinfo_async.c gethostnamadr_async.c 
                         getnameinfo_async.c getrrsetbyname.c 
                         getrrsetbyname_async.c res_search_async.c 
                         res_send_async.c 

Log message:
Avoid recursive cleanup in getrrsetbyname()
Instead of freeing struct dns_query and struct dns_rr by walking the
linked lists recursively, use a simple loop. This avoids a possible
stack exhaustion unlikely to be reachable with the limits modern
resolvers impose.
>From Dhiraj Mishra
from tb@; OK djm@

Ensure asr's sockets are close-on-exec to avoid a potential leak into children.
from dgl@; OK jca@ brynet@

Skip aliases that are not valid hostnames in gethostbyname(3).
Consider the following CNAME chain:
chain7.narrans.de.      60      IN      CNAME   chain\007.tlakh.xyz.
chain\007.tlakh.xyz.    60      IN      CNAME   chain.sha256.net.
chain.sha256.net.       60      IN      CNAME   sha256.net.
sha256.net.             60      IN      A       213.239.192.17
gethostbyname(3) would fail the query when it encounters
chain\007.tlakh.xyz. and tries to add it to h_aliases member of struct
hostent because it's not a valid hostname. This in turn would fail the
whole query.
With this, resolution succeeds and we get an alias list of
"chain7.narrans.de chain.sha256.net".
hostent_add_alias() can no longer fail, so make it void.
Noticed by dgl while we were working on something else.
from florian@; OK deraadt@

Reject empty CNAMEs in gethostbyname(3) / getaddrinfo(3).
An empty string is arguably not a correct hostname (even though
res_hnok accepts it). More worrisome though is software not expecting
this and making mistakes. In practice this cannot happen unless the
resolver lies to us.
from florian@; OK deraadt@ jca@

Check for errors returned by _asr_unpack_{header,query,rr}
dname_expand() is the main parsing function for DNS labels. Its errors
are propagated via unpack_dname() to _asr_unpack_query() and
_asr_unpack_rr().
Those two functions would also propagate the errors, but they were
then ignored by the callers which would continue parsing invalid DNS
data.
_asr_unpack_header has the same issue but the call chain is shorter.
from florian@; input & OK deraadt@

Nothing to do if we get a zero length buffer; from Andrew Griffiths
from florian@; OK deraadt@

Check for IPv6 scope truncation in getnameinfo(3); from Andrew Griffiths
from florian@; OK deraadt@

Avoid a bunch of useless checks, free(NULL) is valid.
While here, use a counter of type unsigned int, which is the same type
as rri_nrdatas in our termination condition. (In practice there can't
be more than 65k RRSets).
Andrew Griffiths pointed out that we'd leak memory if rri_rdatas or
rri_sigs are sparsely populated. In practice this will not happen but
it made me look.
from florian@; OK deraadt@

ttl is u_int32_t; from Andrew Griffiths
from florian@; OK deraadt@

_asr_make_fqdn() indicates error by returning 0; from Andrew Griffiths
from florian@; OK deraadt@

Reset ar_datalen and ar_data after free(3) like everywhere else.
>From Andrew Griffiths
from florian@

Do not silently truncate result of dname_expand.
This can only happen if the caller provides a buffer that's too
small. All current callers provide a buffer of size MAXDNAME, which is
large enough in all cases, otherwise dname_check_label would error out.
Found by me and independently by Andrew Griffiths.
from florian@; OK deraadt@ tb@

Return statically built addresses when hostname == NULL  It always
returns IPv4 and IPv6 addresses when hostname == NULL; previously, it
returned only the address of the selected address family defined by
"family" in resolv.conf.
from yasuoka@; OK florian@

Use decimal encoding for special characters in DNS labels.
with dgl some time ago
from florian@; OK dlg@

DNS names are not proper C strings, they can contain NUL octets.
If we want to use string functions (e.g. for comparison) we first need
to convert them.
with dgl some time ago
from florian@; OK dlg@

off-by-one in unpack_dname can smash 1 extra byte.
from Acts1631
from deraadt@; OK otto@ florian@ millert@

this is errata/7.9/050_libcasr.patch.sig

Reply via email to