]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-netlink: fix invalid assertion
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 15 Sep 2019 13:50:36 +0000 (22:50 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 17 Sep 2019 12:53:42 +0000 (21:53 +0900)
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.

src/libsystemd/sd-netlink/netlink-message.c

index ddfb3ae96c79c11b4500a135449896f09bca8675..16964712c91621ac2b8571376e06df2bf9a77f41 100644 (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];