Commit 23e9e2e
committed
Fix cpnet_getHostByName return value on error
In platforms lacking gethostbyname_r, such as Darwin (macOS),
cpnet_getHostByName incorrectly returns -errno when gethostbyname
fails. It should return -h_errno instead.
Since errno is not set by gethostbyname, the value returned by
cpnet_getHostByName is undefined at that point. It could be 0 or
a stale value from a previous unrelated system call.
If cpnet_getHostByName returns 0 (CPNATIVE_OK) the caller
(Java_java_net_VMInetAddress_getHostByName) then proceeds to
access the addresses pointer, which was never initialized,
typically leading to a crash (SIGBUS/SIGSEGV).
Fix by returning -h_errno on error.
Fixes #37 (BZ#124082)
Signed-off-by: Guillermo Rodríguez <grodriguez@ingelabs.com>1 parent b1510ee commit 23e9e2e
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
661 | 661 | | |
662 | 662 | | |
663 | 663 | | |
664 | | - | |
| 664 | + | |
665 | 665 | | |
666 | 666 | | |
667 | 667 | | |
| |||
0 commit comments