Expected outcome of passing null *name ptr to ares_getaddrinfo()

Carson Vandegriffe carson.vandegriffe at candelatech.com
Thu Mar 14 00:39:59 CET 2024


Hi all,

I've been working on an effort to override some (libc) /getaddrinfo()/ 
calls into /ares_getaddrinfo()/ calls (see recent mail regarding 
LD_PRELOAD). I notice that in some cases, /getaddrinfo()/ is getting 
passed a null /node/ pointer. In the docs for the function, it states that:

"Either/node/  or/service/, but not both, may be NULL."

and that:

"If/node/  is NULL, then the network address will be set to the loopback interface address ..."


Now in the /ares_getaddrinfo() /docs, the equivalent behavior of passing 
in a null /name/ pointer is undefined. And I'm seeing the following 
segfault splat when a null /name/ pointer is used:

#0  __strchr_avx2 () at ../sysdeps/x86_64/multiarch/strchr-avx2.S:65
#1  0x00007f3e02488848 in ares__single_domain (channel=0x1daa7f0, name=0x0, s=0x7ffc98f50608) at ares_search.c:288
#2  0x00007f3e0247ec49 in ares_getaddrinfo_int (channel=0x1daa7f0, name=0x0, service=0x7ffc98f50912 "5201",
     hints=0x7ffc98f507e0, callback=0x7f3e0266a376 <ai_callback>, arg=0x7ffc98f50918) at ares_getaddrinfo.c:568
#3  0x00007f3e0247f14e in ares_getaddrinfo (channel=0x1daa7f0, name=0x0, service=0x7ffc98f50912 "5201",
     hints=0x7ffc98f507e0, callback=0x7f3e0266a376 <ai_callback>, arg=0x7ffc98f50918) at ares_getaddrinfo.c:681
#4  0x00007f3e0266a9fb in getaddrinfo (libc_node=0x0, libc_service=0x7ffc98f50912 "5201", libc_hints=0x7ffc98f50920,
     libc_res=0x7ffc98f50918) at intercept.c:158

So I was curious, what is the expected behavior when a null /name/ 
pointer is passed into /ares_getaddrinfo()/?

Thanks,

Carson
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.haxx.se/pipermail/c-ares/attachments/20240313/2bb9e606/attachment.htm>


More information about the c-ares mailing list