Bug 18276 – Inconsistent assumption about result of InternetHost.getHostByName

Status
NEW
Severity
minor
Priority
P3
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-01-22T11:37:41Z
Last change time
2024-12-01T16:32:07Z
Assigned to
No Owner
Creator
MichaelZ
Moved to GitHub: phobos#10295 →

Comments

Comment #0 by dlang.org — 2018-01-22T11:37:41Z
One of the InternetAddress constructors https://github.com/dlang/phobos/blob/v2.078.0/std/socket.d#L1563 assumes that a succesful InternetHost.gethostbyname call results in at least one entry in addrList. The implementation of InternetHost.populate, which fills addrList: https://github.com/dlang/phobos/blob/v2.078.0/std/socket.d#L704-L716 has a case where addrList remains null. This at least *looks* like a problem; either the addrList = null case in populate should never be reached, or the assumption in the InternetAddress constructor is invalid, right? I came to look at this because I had code which tripped an out of range exception on https://github.com/dlang/phobos/blob/v2.078.0/std/socket.d#L1563 . In my case this may have been due to use of gethostbyname by a third party (non-D) library, which obviously didn't respect the phobos mutex around gethostbyname. My workaround is currently to not use InternetAddress at all. gethostbyname is deprecated in any case (=> https://issues.dlang.org/show_bug.cgi?id=15424), so maybe a rewrite or deprecation here is in order anyway?
Comment #1 by robert.schadek — 2024-12-01T16:32:07Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10295 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB