summaryrefslogtreecommitdiffstats
path: root/src/nss-resolve
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2019-01-18 20:13:55 +0100
committerLennart Poettering <lennart@poettering.net>2019-02-08 10:34:47 +0100
commitcdccd29f39cd20cb2a8b71e50445eb839f076331 (patch)
tree22361057d01ea2c1aae6246546b4d00fc28a7349 /src/nss-resolve
parentutil.h: add new UNPROTECT_ERRNO macro (diff)
downloadsystemd-cdccd29f39cd20cb2a8b71e50445eb839f076331.tar.xz
systemd-cdccd29f39cd20cb2a8b71e50445eb839f076331.zip
nss: unportect errno before writing to NSS' *errnop
Fixes: #11321
Diffstat (limited to 'src/nss-resolve')
-rw-r--r--src/nss-resolve/nss-resolve.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/nss-resolve/nss-resolve.c b/src/nss-resolve/nss-resolve.c
index a28b5d8ba8..8370fed076 100644
--- a/src/nss-resolve/nss-resolve.c
+++ b/src/nss-resolve/nss-resolve.c
@@ -186,6 +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) {
+ UNPROTECT_ERRNO;
*errnop = ERANGE;
*h_errnop = NETDB_INTERNAL;
return NSS_STATUS_TRYAGAIN;
@@ -267,6 +268,7 @@ enum nss_status _nss_resolve_gethostbyname4_r(
return NSS_STATUS_SUCCESS;
fail:
+ UNPROTECT_ERRNO;
*errnop = -r;
*h_errnop = NO_RECOVERY;
return ret;
@@ -364,6 +366,7 @@ enum nss_status _nss_resolve_gethostbyname3_r(
ms = ALIGN(l+1) + c * ALIGN(alen) + (c+2) * sizeof(char*);
if (buflen < ms) {
+ UNPROTECT_ERRNO;
*errnop = ERANGE;
*h_errnop = NETDB_INTERNAL;
return NSS_STATUS_TRYAGAIN;
@@ -455,6 +458,7 @@ enum nss_status _nss_resolve_gethostbyname3_r(
return NSS_STATUS_SUCCESS;
fail:
+ UNPROTECT_ERRNO;
*errnop = -r;
*h_errnop = NO_RECOVERY;
return ret;
@@ -492,12 +496,14 @@ enum nss_status _nss_resolve_gethostbyaddr2_r(
assert(h_errnop);
if (!IN_SET(af, AF_INET, AF_INET6)) {
+ UNPROTECT_ERRNO;
*errnop = EAFNOSUPPORT;
*h_errnop = NO_DATA;
return NSS_STATUS_UNAVAIL;
}
if (len != FAMILY_ADDRESS_SIZE(af)) {
+ UNPROTECT_ERRNO;
*errnop = EINVAL;
*h_errnop = NO_RECOVERY;
return NSS_STATUS_UNAVAIL;
@@ -576,6 +582,7 @@ enum nss_status _nss_resolve_gethostbyaddr2_r(
c * sizeof(char*); /* pointers to aliases, plus trailing NULL */
if (buflen < ms) {
+ UNPROTECT_ERRNO;
*errnop = ERANGE;
*h_errnop = NETDB_INTERNAL;
return NSS_STATUS_TRYAGAIN;
@@ -636,6 +643,7 @@ enum nss_status _nss_resolve_gethostbyaddr2_r(
return NSS_STATUS_SUCCESS;
fail:
+ UNPROTECT_ERRNO;
*errnop = -r;
*h_errnop = NO_RECOVERY;
return ret;