]> git.ipfire.org Git - thirdparty/lxc.git/commit
nl: avoid NULL pointer dereference 2497/head
authorRafał Miłecki <rafal@milecki.pl>
Sun, 29 Jul 2018 15:44:06 +0000 (17:44 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sun, 29 Jul 2018 16:36:18 +0000 (18:36 +0200)
commitc8f05589644d6b719e5a2c7fc548604f248be9be
treec8330c885d9ee4b84454a65cdd8d0cbf1557a1f8
parenta4f181a448b292fe12f07f435fe55c873899ea8c
nl: avoid NULL pointer dereference

It's a valid case to call nla_put() with NULL data and 0 len. It's done e.g. in
the nla_put_attr().

There has to be a check for data in nla_put() as passing NULL to the memcpy()
is not allowed. Even if length is 0, both pointers have to be valid.

For a reference see C99 standard (7.21.1/2), it says: "pointer arguments on
such a call shall still have valid values".

Reported-by: Daniel Gimpelevich <daniel@gimpelevich.san-francisco.ca.us>
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
[christian.brauner@ubuntu.com: adapted commit message]
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/nl.c