netlink-socket: Avoid use-after-free in nl_lookup_genl_mcgroup().
authorBen Pfaff <blp@nicira.com>
Fri, 9 Sep 2011 17:21:49 +0000 (10:21 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 9 Sep 2011 23:40:16 +0000 (16:40 -0700)
commit2a477244f7479055bca01450eb61ae553a5108a4
tree078fecef8e9ab3ec7e46fa84687dd4207d9e81cd
parent0d1fe4a36287a2e107f96e50a6ab3556da3726a3
netlink-socket: Avoid use-after-free in nl_lookup_genl_mcgroup().

Commit e408762f "netlink-socket: New function nl_lookup_genl_mcgroup()"
modified do_lookup_genl_family() to return the Netlink attributes to the
caller, but it still freed the Netlink message itself, which meant that
the attributes pointed into freed memory.  This commit fixes the problem.

This commit is not a minimal fix.  It refactors do_lookup_genl_family(),
changing the return value from "negative errno value or positive genl
family id" to the more common "zero or positive errno value".

Found by valgrind.
lib/netlink-socket.c