sysdeps-unix: Handle errors from getaddrinfo correctly
authorSimon McVittie <smcv@collabora.com>
Mon, 4 Jun 2018 15:27:46 +0000 (16:27 +0100)
committerSimon McVittie <smcv@collabora.com>
Mon, 4 Jun 2018 16:55:21 +0000 (17:55 +0100)
commit8ec0b5ae2d9bce65d8246204b90a9d2552f337e7
treeb4745421d94001540baba0bfa34182a992b5e228
parent6c3e82af25e584acf769419be84c04ab7b944859
sysdeps-unix: Handle errors from getaddrinfo correctly

getaddrinfo and getnameinfo have their own error-handling convention
in which the library call returns either 0 or an EAI_* error code
unrelated to errno. If the error code is not EAI_SYSTEM, then
the value of errno is undefined (in particular it might be carried
over from a previous system call or library call). Introduce a
new helper function _dbus_error_from_gai() to handle this.

The equivalent code paths in Windows appear to be OK: the Windows
implementation of getaddrinfo() is documented to return a Winsock
error code, which we seem to be handling correctly.

Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=106395
(cherry picked from commit 60cedd0cfd775c9fcf7260e12af9b2ffeefc2bbe)
dbus/dbus-sysdeps-unix.c