const char *mask = strtok_r(NULL, "/", &saveptr);
if (!addr || inet_pton(af, addr, &route->source) < 1) {
- DPRINTF("Failed to parse route source: %s\n", addr);
+ DPRINTF("Failed to parse route source: %s\n", addr ? addr : "NULL");
goto error;
}
// End-of-assignment sentinel
c = malloc(sizeof(*c) + 1);
+ if (!c)
+ return;
+
c->assigned = 1 << (64 - prefix->length);
c->length = 64;
c->name[0] = 0;
if (prefix->excl_length > 0) {
const char name[] = "!excluded";
c = malloc(sizeof(*c) + sizeof(name));
- c->assigned = ntohl(prefix->excl_addr.s6_addr32[1]) &
- ((1 << (64 - prefix->length)) - 1);
- c->length = prefix->excl_length;
- c->addr = in6addr_any;
- memcpy(c->name, name, sizeof(name));
- list_add(&c->head, &prefix->assignments);
+ if (c) {
+ c->assigned = ntohl(prefix->excl_addr.s6_addr32[1]) &
+ ((1 << (64 - prefix->length)) - 1);
+ c->length = prefix->excl_length;
+ c->addr = in6addr_any;
+ memcpy(c->name, name, sizeof(name));
+ list_add(&c->head, &prefix->assignments);
+ }
}
bool assigned_any = false;
size_t namelen = strlen(iface->name) + 1;
c = malloc(sizeof(*c) + namelen);
+ if (!c)
+ continue;
+
c->length = iface->assignment_length;
c->assigned = iface->assignment_hint;
c->addr = in6addr_any;
pclass = (iface) ? iface->name : "local";
struct device_prefix *prefix = calloc(1, sizeof(*prefix) + strlen(pclass) + 1);
+ if (!prefix)
+ return NULL;
+
prefix->length = length;
prefix->addr = *addr;
prefix->preferred_until = preferred_until;