sd-netlink: fix invalid assertion

It is natural that n_attiributes is less than type. But in that case,
the message does not contain any message about the type. So, we should
not abort execution with assertion, but just return -ENODATA.
This commit is contained in:
Yu Watanabe 2019-09-15 22:50:36 +09:00
parent 69cebea78a
commit 48fb0d1301

View file

@ -577,7 +577,9 @@ static int netlink_message_read_internal(sd_netlink_message *m, unsigned short t
assert(m->n_containers < RTNL_CONTAINER_DEPTH);
assert(m->containers[m->n_containers].attributes);
assert(type < m->containers[m->n_containers].n_attributes);
if (type >= m->containers[m->n_containers].n_attributes)
return -ENODATA;
attribute = &m->containers[m->n_containers].attributes[type];