Unify dns_*() function definitions for all platforms
Description
This is a todo in the code
I'm putting it here so it gets on the radar for a todo. If this is a wontfix then remove the todo from the code.
Changes to this code segment caused an issue #7748 with the output of gethostbyaddr() showing as a binary string in Windows.
/* TODO: Reimplement the gethostby* functions using the new winxp+ API, in dns_win32.c, then
we can have a dns.c, dns_unix.c and dns_win32.c instead of a messy dns.c full of #ifdef
*/
This comment confuses me. The implementation of the gethostby*() function looks reasonable; the implementation of the dns_*() functions appears to be the actual issue, since back then they have been implemented in dns_win32.c as full PHP functions, which already caused issues, because it's indeed easily overlooked that their implementation in dns.c is not the only one available. Improving this makes sense to me.
I wouldn't know, though, to which "new winxp+ API" the comment is referring. Maybe it's about using DnsQueryEx instead of DnsQuery, but the former is only available as of Windows 8/Server 2012.
The comment is 13 years old, so...
Unassigning for time reasons; I hope to get back to this in a while, but wouldn't be sad, if somebody else beats me to it.
@cmb69 I wrote that if I remember correctly, in 5.3 windows port time.
What is the fixed issue exactly in the referred commit? I added a comment for @remicollet in the referred ticket, I don't really understand the use of getnameinfo for gethostbyaddr (which should really map what gethostbyaddr does :)
This comment confuses me. The implementation of the
gethostby*()function looks reasonable; the implementation of thedns_*()functions appears to be the actual issue, since back then they have been implemented indns_win32.cas full PHP functions, which already caused issues,
It does not for 13 years. This was the only way to have clean codes somehow without massive functions full of #ifdef.
For what I see, the culprit is the change from getaddrinfo to getnameinfo for php_getaddrinfo, both functions do not behave the same and do not aim for the same features. Let see why it was changed then we can advise about the best fix :)
because it's indeed easily overlooked that their implementation in
dns.cis not the only one available. Improving this makes sense to me.
@pierrejoye, I think this is not particularly about the change from getaddrinfo to getnameinfo, but rather that we define the PHP functions in two different files. Few years ago there was a security issue related to the Windows implementation (NUL byte injection), that had already been fixed years ago for the Linux implementation. If the actual PHP function implementations are that different, it would still make sense to move them into a separate inlined C function.