diff options
author | Sam Morris <sam@robots.org.uk> | 2019-01-09 10:15:53 +0000 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-01-10 11:08:42 +0100 |
commit | b26c90411343d74b15deb24bd87077848e316dab (patch) | |
tree | 4379707a38479aae6e472b146692c18ed470dd97 /src/nss-resolve | |
parent | a1b939dfc74f1f6ac8e8ad41912ac322b5e2438c (diff) | |
download | systemd-b26c90411343d74b15deb24bd87077848e316dab.tar.gz |
nss: prevent PROTECT_ERRNO from squashing changes to *errnop
glibc passes in &errno for errnop, which means PROTECT_ERRNO ends up
squashing our intentional changes to *errnop.
Fixes #11321.
Diffstat (limited to 'src/nss-resolve')
-rw-r--r-- | src/nss-resolve/nss-resolve.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/nss-resolve/nss-resolve.c b/src/nss-resolve/nss-resolve.c index a28b5d8ba8..a283384f90 100644 --- a/src/nss-resolve/nss-resolve.c +++ b/src/nss-resolve/nss-resolve.c @@ -186,7 +186,7 @@ enum nss_status _nss_resolve_gethostbyname4_r( l = strlen(canonical); ms = ALIGN(l+1) + ALIGN(sizeof(struct gaih_addrtuple)) * c; if (buflen < ms) { - *errnop = ERANGE; + *errnop = DISARM_PROTECT_ERRNO(ERANGE); *h_errnop = NETDB_INTERNAL; return NSS_STATUS_TRYAGAIN; } @@ -267,7 +267,7 @@ enum nss_status _nss_resolve_gethostbyname4_r( return NSS_STATUS_SUCCESS; fail: - *errnop = -r; + *errnop = DISARM_PROTECT_ERRNO(r); *h_errnop = NO_RECOVERY; return ret; @@ -364,7 +364,7 @@ enum nss_status _nss_resolve_gethostbyname3_r( ms = ALIGN(l+1) + c * ALIGN(alen) + (c+2) * sizeof(char*); if (buflen < ms) { - *errnop = ERANGE; + *errnop = DISARM_PROTECT_ERRNO(ERANGE); *h_errnop = NETDB_INTERNAL; return NSS_STATUS_TRYAGAIN; } @@ -455,7 +455,7 @@ enum nss_status _nss_resolve_gethostbyname3_r( return NSS_STATUS_SUCCESS; fail: - *errnop = -r; + *errnop = DISARM_PROTECT_ERRNO(r); *h_errnop = NO_RECOVERY; return ret; @@ -492,13 +492,13 @@ enum nss_status _nss_resolve_gethostbyaddr2_r( assert(h_errnop); if (!IN_SET(af, AF_INET, AF_INET6)) { - *errnop = EAFNOSUPPORT; + *errnop = DISARM_PROTECT_ERRNO(EAFNOSUPPORT); *h_errnop = NO_DATA; return NSS_STATUS_UNAVAIL; } if (len != FAMILY_ADDRESS_SIZE(af)) { - *errnop = EINVAL; + *errnop = DISARM_PROTECT_ERRNO(EINVAL); *h_errnop = NO_RECOVERY; return NSS_STATUS_UNAVAIL; } @@ -576,7 +576,7 @@ enum nss_status _nss_resolve_gethostbyaddr2_r( c * sizeof(char*); /* pointers to aliases, plus trailing NULL */ if (buflen < ms) { - *errnop = ERANGE; + *errnop = DISARM_PROTECT_ERRNO(ERANGE); *h_errnop = NETDB_INTERNAL; return NSS_STATUS_TRYAGAIN; } @@ -636,7 +636,7 @@ enum nss_status _nss_resolve_gethostbyaddr2_r( return NSS_STATUS_SUCCESS; fail: - *errnop = -r; + *errnop = DISARM_PROTECT_ERRNO(r); *h_errnop = NO_RECOVERY; return ret; |