chiark / gitweb /
sd-netlink: make sure the root-level type is nested
authorDavid Herrmann <dh.herrmann@gmail.com>
Tue, 23 Jun 2015 08:47:44 +0000 (10:47 +0200)
committerSven Eden <yamakuzure@gmx.net>
Tue, 14 Mar 2017 09:04:18 +0000 (10:04 +0100)
commit724ccdb94309bde65b4e067f7d61f0170e0bbdb2
treeab54824e1835ac031b72de0a46582c0c0469079b
parenta2db88febce62dac4846d17e903c0046b4749caf
sd-netlink: make sure the root-level type is nested

In sd-netlink-message, we always guarantee that the currently selected
type-system is non-NULL. Otherwise, we would be unable to parse any types
in the current container level. Hence, this assertion must be true:
    message->container_type_system[m->n_containers] != NULL

During message_new() we currently do not verify that this assertion is
true. Instead, we blindly access nl_type->type_system and use it (which
might be NULL for basic types and unions). Fix this, by explicitly
checking that the root-level type is nested.

Note that this is *not* a strict requirement of netlink, but it's a strict
requirement for all message types we currently support. Furthermore, all
the callers of message_new() already verify that only supported types are
passed, therefore, this is a pure cosmetic check. However, it might be
needed on the future, so make sure we don't trap into this once we change
the type-system.
src/libsystemd/sd-netlink/netlink-message.c