Summary: | should not assume that getaddrinfo sets errno | ||
---|---|---|---|
Product: | dbus | Reporter: | Simon McVittie <smcv> |
Component: | core | Assignee: | Simon McVittie <smcv> |
Status: | RESOLVED FIXED | QA Contact: | D-Bus Maintainers <dbus> |
Severity: | normal | ||
Priority: | medium | Keywords: | patch |
Version: | git master | ||
Hardware: | Other | ||
OS: | All | ||
Whiteboard: | review+ | ||
i915 platform: | i915 features: | ||
Bug Depends on: | |||
Bug Blocks: | 106812 | ||
Attachments: | sysdeps-unix: Handle errors from getaddrinfo correctly |
Description
Simon McVittie
2018-05-03 22:39:56 UTC
Created attachment 140010 [details] [review] 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. Comment on attachment 140010 [details] [review] sysdeps-unix: Handle errors from getaddrinfo correctly Review of attachment 140010 [details] [review]: ----------------------------------------------------------------- ::: dbus/dbus-sysdeps-unix.c @@ +1327,5 @@ > > +/* Convert an error code from getaddrinfo() or getnameinfo() into > + * a D-Bus error name. */ > +static const char * > +_dbus_error_from_gai (int gai_res, I chose this naming because gai seems to be a conventional name for the RFC 2553/RFC 3493 family of functions (they use gai_strerror() and, in glibc, are configurable via gai.conf). Comment on attachment 140010 [details] [review] sysdeps-unix: Handle errors from getaddrinfo correctly Review of attachment 140010 [details] [review]: ----------------------------------------------------------------- r+ Fixed in git for 1.13.6, and I'm testing cherry-picked versions for 1.12.10. Thanks for the reviews! (In reply to Simon McVittie from comment #1) > 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. Thanks for looking into the Windows part. |
Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.