forked from pool/systemd
39 lines
1.3 KiB
Diff
39 lines
1.3 KiB
Diff
|
From: Ludwig Nussel <ludwig.nussel@suse.de>
|
||
|
Date: Mon, 26 Nov 2012 09:49:42 +0100
|
||
|
Subject: avoid assertion if invalid address familily is passed to
|
||
|
gethostbyaddr_r (bnc#791101)
|
||
|
|
||
|
---
|
||
|
src/nss-myhostname/nss-myhostname.c | 11 ++++++-----
|
||
|
1 file changed, 6 insertions(+), 5 deletions(-)
|
||
|
|
||
|
diff --git a/src/nss-myhostname/nss-myhostname.c b/src/nss-myhostname/nss-myhostname.c
|
||
|
index b0fb832..b3aaca8 100644
|
||
|
--- a/src/nss-myhostname/nss-myhostname.c
|
||
|
+++ b/src/nss-myhostname/nss-myhostname.c
|
||
|
@@ -384,6 +384,12 @@ enum nss_status _nss_myhostname_gethostbyaddr2_r(
|
||
|
struct address *addresses = NULL, *a;
|
||
|
unsigned n_addresses = 0, n;
|
||
|
|
||
|
+ if (af != AF_INET && af != AF_INET6) {
|
||
|
+ *errnop = EAFNOSUPPORT;
|
||
|
+ *h_errnop = NO_DATA;
|
||
|
+ return NSS_STATUS_UNAVAIL;
|
||
|
+ }
|
||
|
+
|
||
|
if (len != PROTO_ADDRESS_SIZE(af)) {
|
||
|
*errnop = EINVAL;
|
||
|
*h_errnop = NO_RECOVERY;
|
||
|
@@ -399,11 +405,6 @@ enum nss_status _nss_myhostname_gethostbyaddr2_r(
|
||
|
|
||
|
if (memcmp(addr, LOCALADDRESS_IPV6, 16) == 0)
|
||
|
goto found;
|
||
|
-
|
||
|
- } else {
|
||
|
- *errnop = EAFNOSUPPORT;
|
||
|
- *h_errnop = NO_DATA;
|
||
|
- return NSS_STATUS_UNAVAIL;
|
||
|
}
|
||
|
|
||
|
ifconf_acquire_addresses(&addresses, &n_addresses);
|