[PATCH] getaddrinfo and getnameinfo in libirs

Petr Mensik pemensik at redhat.com
Tue Feb 21 12:49:17 UTC 2017


Hi.

It was pointed to me that bind libirs library provides getaddrinfo without prefix. That makes any program that uses dynamic linking use libirs implementation.
I am not sure if that is intended behavior. There is problem with that with dhcp server, if it is compiled --with-ldap and links against bind library.
Problem is if application passes flag that libirs does not support, it will always fail without simple workaround. Like AI_ADDRCONFIG in ldap library.

There is also second error I found in delv utility. Because it does link libirs, it will use its getaddrinfo. You cannot use any name defined in /etc/hosts because of that,
it will only ask nameserver(s). Is that required to validate domain names in secure way? This behavior is different between dig and delv, because dig does not link libirs.

I think this is error and already reported it as suggestion #44024.

There is also problem with constants in irs/netdb.h. They undefine all constants from system netdb.h and redefine them to its own values.
But those values have to be equal to system values, because all files include only system header when calling getaddrinfo.
If value would be different, implementation in getaddrinfo would silently work with it wrong way.

I think such reimplementation of system call is really strange. Do you know any reasons for own implementation?
I have checked documentation and getaddrinfo is provided even on all Windows since XP, with all three supported flags.
But is missing flags like AI_IDN supported by recent glibc.

Are system calls on some platforms thread unsafe? Or does it use isc_mem contexts to discover leaked memory?
Is there any advantage over using gai calls provided by system libraries?

I made patches, that will add prefix to those libraries. If you include irs/netdb.h, it will define macros that allows you to have the same code.
But it removes conflict with glibc, so you or any other library linked into your program can still use custom implementation and also system calls.

The second patch makes it possible to build libirs without custom getaddrinfo. I think it should be default if system call is able to provide all required functions.
Do you know supported platform that does not provide sufficient getaddrinfo call? It seems to work well to me. Those patches are against bind 9.9.

I hope there is reason why it is not implemented like this already. I would like to hear it, please share if you know something?

Cheers,
Petr
--
Petr Menšík
Software Engineer
Red Hat, http://www.redhat.com/
email: pemensik at redhat.com  PGP: 65C6C973

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Prefix-provided-getaddrinfo-in-libirs-with-irs_.patch
Type: text/x-patch
Size: 11430 bytes
Desc: not available
URL: <https://lists.isc.org/pipermail/bind-workers/attachments/20170221/1e211c96/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Allow-usage-of-getaddrinfo-provided-by-the-system.patch
Type: text/x-patch
Size: 6427 bytes
Desc: not available
URL: <https://lists.isc.org/pipermail/bind-workers/attachments/20170221/1e211c96/attachment-0001.bin>


More information about the bind-workers mailing list