1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-18 06:03:42 +03:00

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.

(cherry picked from commit 48fb0d1301c78112360df943f2b6ebeb545b8510)
(cherry picked from commit a321507476af07b9ce743608a15156f2bc43da1d)
(cherry picked from commit e6e168388d003761a61319a696c7e419d374a980)
(cherry picked from commit ea44afca1be770dfb1e0a1c4a8315f8cdd3cafab)
This commit is contained in:
Yu Watanabe 2019-09-15 22:50:36 +09:00 committed by Zbigniew Jędrzejewski-Szmek
parent 8aabc03800
commit dc25432f92

View File

@ -551,7 +551,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];