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-mymachines/nss-mymachines.c | |
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-mymachines/nss-mymachines.c')
-rw-r--r-- | src/nss-mymachines/nss-mymachines.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/nss-mymachines/nss-mymachines.c b/src/nss-mymachines/nss-mymachines.c index 3d1fc28353..332d440a51 100644 --- a/src/nss-mymachines/nss-mymachines.c +++ b/src/nss-mymachines/nss-mymachines.c @@ -153,7 +153,7 @@ enum nss_status _nss_mymachines_gethostbyname4_r( l = strlen(name); 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; } @@ -227,7 +227,7 @@ enum nss_status _nss_mymachines_gethostbyname4_r( return NSS_STATUS_SUCCESS; fail: - *errnop = -r; + *errnop = DISARM_PROTECT_ERRNO(r); *h_errnop = NO_DATA; return NSS_STATUS_UNAVAIL; } @@ -313,7 +313,7 @@ enum nss_status _nss_mymachines_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; } @@ -396,7 +396,7 @@ enum nss_status _nss_mymachines_gethostbyname3_r( return NSS_STATUS_SUCCESS; fail: - *errnop = -r; + *errnop = DISARM_PROTECT_ERRNO(r); *h_errnop = NO_DATA; return NSS_STATUS_UNAVAIL; } @@ -484,7 +484,7 @@ enum nss_status _nss_mymachines_getpwnam_r( l = strlen(name); if (buflen < l+1) { - *errnop = ERANGE; + *errnop = DISARM_PROTECT_ERRNO(ERANGE); return NSS_STATUS_TRYAGAIN; } @@ -501,7 +501,7 @@ enum nss_status _nss_mymachines_getpwnam_r( return NSS_STATUS_SUCCESS; fail: - *errnop = -r; + *errnop = DISARM_PROTECT_ERRNO(r); return NSS_STATUS_UNAVAIL; } @@ -564,7 +564,7 @@ enum nss_status _nss_mymachines_getpwuid_r( return NSS_STATUS_NOTFOUND; if (snprintf(buffer, buflen, "vu-%s-" UID_FMT, machine, (uid_t) mapped) >= (int) buflen) { - *errnop = ERANGE; + *errnop = DISARM_PROTECT_ERRNO(ERANGE); return NSS_STATUS_TRYAGAIN; } @@ -579,7 +579,7 @@ enum nss_status _nss_mymachines_getpwuid_r( return NSS_STATUS_SUCCESS; fail: - *errnop = -r; + *errnop = DISARM_PROTECT_ERRNO(r); return NSS_STATUS_UNAVAIL; } @@ -662,7 +662,7 @@ enum nss_status _nss_mymachines_getgrnam_r( l = sizeof(char*) + strlen(name) + 1; if (buflen < l) { - *errnop = ERANGE; + *errnop = DISARM_PROTECT_ERRNO(ERANGE); return NSS_STATUS_TRYAGAIN; } @@ -677,7 +677,7 @@ enum nss_status _nss_mymachines_getgrnam_r( return NSS_STATUS_SUCCESS; fail: - *errnop = -r; + *errnop = DISARM_PROTECT_ERRNO(r); return NSS_STATUS_UNAVAIL; } @@ -740,13 +740,13 @@ enum nss_status _nss_mymachines_getgrgid_r( return NSS_STATUS_NOTFOUND; if (buflen < sizeof(char*) + 1) { - *errnop = ERANGE; + *errnop = DISARM_PROTECT_ERRNO(ERANGE); return NSS_STATUS_TRYAGAIN; } memzero(buffer, sizeof(char*)); if (snprintf(buffer + sizeof(char*), buflen - sizeof(char*), "vg-%s-" GID_FMT, machine, (gid_t) mapped) >= (int) buflen) { - *errnop = ERANGE; + *errnop = DISARM_PROTECT_ERRNO(ERANGE); return NSS_STATUS_TRYAGAIN; } @@ -758,6 +758,6 @@ enum nss_status _nss_mymachines_getgrgid_r( return NSS_STATUS_SUCCESS; fail: - *errnop = -r; + *errnop = DISARM_PROTECT_ERRNO(r); return NSS_STATUS_UNAVAIL; } |