struct gaih_addrtuple *r_tuple, *r_tuple_first = NULL;
_cleanup_bus_message_unref_ sd_bus_message* reply = NULL;
_cleanup_bus_unref_ sd_bus *bus = NULL;
- _cleanup_free_ int *ifindexes = NULL;
+ _cleanup_free_ int *ifindices = NULL;
_cleanup_free_ char *class = NULL;
size_t l, ms, idx;
unsigned i = 0, c = 0;
char *r_name;
- int n_ifindexes, r;
+ int n_ifindices, r;
assert(name);
assert(pat);
goto fail;
}
- n_ifindexes = sd_machine_get_ifindexes(name, &ifindexes);
- if (n_ifindexes < 0) {
- r = n_ifindexes;
+ n_ifindices = sd_machine_get_ifindices(name, &ifindices);
+ if (n_ifindices < 0) {
+ r = n_ifindices;
goto fail;
}
goto fail;
if (c <= 0) {
- *errnop = ENOENT;
+ *errnop = ESRCH;
*h_errnop = HOST_NOT_FOUND;
return NSS_STATUS_NOTFOUND;
}
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;
}
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;
r_tuple->next = i == c-1 ? NULL : (struct gaih_addrtuple*) ((char*) r_tuple + ALIGN(sizeof(struct gaih_addrtuple)));
r_tuple->name = r_name;
r_tuple->family = family;
- r_tuple->scopeid = n_ifindexes == 1 ? ifindexes[0] : 0;
+ r_tuple->scopeid = n_ifindices == 1 ? ifindices[0] : 0;
memcpy(r_tuple->addr, a, sz);
idx += ALIGN(sizeof(struct gaih_addrtuple));