asan doesn't like it if we use strndup() (i.e. a string function) on a
non-NULL terminated buffer (i.e. something that isn't really a string).
Let's hence use memdup_suffix0() instead of strndup(), which is more
appropriate for binary data that is to become a string.
Fixes: #10385
end = m->rindex + 0;
else
end = m->rindex + c->item_size;
-
+
m->containers[m->n_containers++] = (struct bus_container) {
.enclosing = type,
.signature = TAKE_PTR(signature),
return -EBADMSG;
if (*p == 0) {
+ char *k;
size_t l;
/* We found the beginning of the signature
p[1 + l - 1] != SD_BUS_TYPE_STRUCT_END)
return -EBADMSG;
- if (free_and_strndup(&m->root_container.signature,
- p + 1 + 1, l - 2) < 0)
+ k = memdup_suffix0(p + 1 + 1, l - 2);
+ if (!k)
return -ENOMEM;
+
+ free_and_replace(m->root_container.signature, k);
break;
}