summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-09-15 22:50:36 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-09-17 21:53:42 +0900
commit48fb0d1301c78112360df943f2b6ebeb545b8510 (patch)
tree58a6db93d2d873cc79567f8a32b465617b922626 /src
parent69cebea78a07f67436108323138356f99bb69d33 (diff)
downloadsystemd-48fb0d1301c78112360df943f2b6ebeb545b8510.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd/sd-netlink/netlink-message.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libsystemd/sd-netlink/netlink-message.c b/src/libsystemd/sd-netlink/netlink-message.c
index ddfb3ae96c..16964712c9 100644
--- a/src/libsystemd/sd-netlink/netlink-message.c
+++ b/src/libsystemd/sd-netlink/netlink-message.c
@@ -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];