[Dnsmasq-discuss] [PATCH] inet_addr and inet_aton replacement

Petr Menšík pemensik at redhat.com
Mon Aug 9 14:14:03 UTC 2021


some of our internal checking tools emit errors when the code is using
outdated function with IPv4 only support. Because IPv6 build-time
support is now required, I think using instead inet_pton would be better.

The first attached patch replaces inet_addr with proper error reporting
function. I think this is without issues.

The second patch replaces inet_ntoa function with similar ntop. It
contains more changes, because more recent function does not use
internal hidden buffer but requires using external. I think
daemon->addrbuff is used for this case usually. It brings more lines of
code. It should also require more strict IP address format. Instead of
"10.0", full "" is required. It might refuse some weird
configuration files. I think it is more correct.

Altough I have feeling some parts should be merged. For example
log_packet from src/rfc2131.c is quite similar to log6_packet from
src/rfc3315.c. They differ in address family handled and different
function signatures. Only IPv4 variant forwards log to UBUS, I expect
that is not intentional difference. I expect differences between
protocols should be as minimal as possible.

What do you think, do those changes make sense?



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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Replace-usage-of-inet_ntoa-with-inet_ntop.patch
Type: text/x-patch
Size: 12161 bytes
Desc: not available
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20210809/b46fc646/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Replace-inet_addr-with-inet_pton.patch
Type: text/x-patch
Size: 2953 bytes
Desc: not available
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20210809/b46fc646/attachment-0001.bin>

More information about the Dnsmasq-discuss mailing list