Advertisement

getaddrinfo() returning broadcast address

Started by October 05, 2024 04:57 AM
1 comment, last by Alberth 5 hours, 15 minutes ago

I've recently come across a new behavior from getaddrinfo() that I'm curious if anyone else has seen. Namely, I have a Microsoft Azure virtual machine (IPv4, Windows Server), with a dedicated name (foobar.centralus.cloudapp.azure.com, as a fake example) and dynamically allocated/assigned IP address. When this machine is running, a getaddrinfo() query from a different (Win10) machine returns the expected public IP address. Previously, when this machine was stopped and deallocated, getaddrinfo() would return an error as expected. However, recently I've seen the case be that getaddrinfo() will return success, but with the address being the broadcast address (255.255.255.255). There are no other records returned.

This would appear to be a (new) quirk of Microsoft Azure's VM DNS/IP management, basically saying “I know that DNS name, but there is no IP address allocated for it”. My expectation (and the previous behavior) would be for the DNS lookup to simply fail.

Has anyone seen this kind of behavior in this or any other context? Is there even a scenario where one could validly expect to get the broadcast address from getaddrinfo()?

For the time being it's enough for me to simply treat getting the broadcast address back as failure, but I'd be curious to hear anyone else's experience with this particular behavior.

You may want to check how the function is defined, and compare observed behavior against the definition.

Advertisement