mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-25 06:03:40 +03:00
nss: various minor fixes to nss-myhostname + nss-mymachines
This commit is contained in:
parent
1fa65c593c
commit
555bd6e95b
@ -387,6 +387,12 @@ enum nss_status _nss_myhostname_gethostbyaddr2_r(
|
||||
assert(errnop);
|
||||
assert(h_errnop);
|
||||
|
||||
if (!IN_SET(af, AF_INET, AF_INET6)) {
|
||||
*errnop = EAFNOSUPPORT;
|
||||
*h_errnop = NO_DATA;
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
}
|
||||
|
||||
if (len != PROTO_ADDRESS_SIZE(af)) {
|
||||
*errnop = EINVAL;
|
||||
*h_errnop = NO_RECOVERY;
|
||||
@ -404,17 +410,14 @@ enum nss_status _nss_myhostname_gethostbyaddr2_r(
|
||||
goto found;
|
||||
}
|
||||
|
||||
} else if (af == AF_INET6) {
|
||||
} else {
|
||||
assert(af == AF_INET6);
|
||||
|
||||
if (memcmp(addr, LOCALADDRESS_IPV6, 16) == 0) {
|
||||
additional = "localhost";
|
||||
goto found;
|
||||
}
|
||||
|
||||
} else {
|
||||
*errnop = EAFNOSUPPORT;
|
||||
*h_errnop = NO_DATA;
|
||||
return NSS_STATUS_UNAVAIL;
|
||||
}
|
||||
|
||||
n_addresses = local_addresses(&addresses);
|
||||
|
@ -131,7 +131,7 @@ enum nss_status _nss_mymachines_gethostbyname4_r(
|
||||
goto fail;
|
||||
|
||||
if (c <= 0) {
|
||||
*errnop = ENOENT;
|
||||
*errnop = ESRCH;
|
||||
*h_errnop = HOST_NOT_FOUND;
|
||||
return NSS_STATUS_NOTFOUND;
|
||||
}
|
||||
@ -140,7 +140,7 @@ enum nss_status _nss_mymachines_gethostbyname4_r(
|
||||
ms = ALIGN(l+1) + ALIGN(sizeof(struct gaih_addrtuple)) * c;
|
||||
if (buflen < ms) {
|
||||
*errnop = ENOMEM;
|
||||
*h_errnop = NO_RECOVERY;
|
||||
*h_errnop = TRY_AGAIN;
|
||||
return NSS_STATUS_TRYAGAIN;
|
||||
}
|
||||
|
||||
@ -168,6 +168,11 @@ enum nss_status _nss_mymachines_gethostbyname4_r(
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
|
||||
if (!IN_SET(family, AF_INET, AF_INET6)) {
|
||||
r = -EAFNOSUPPORT;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (sz != PROTO_ADDRESS_SIZE(family)) {
|
||||
r = -EINVAL;
|
||||
goto fail;
|
||||
|
Loading…
x
Reference in New Issue
Block a user