]> git.proxmox.com Git - mirror_lxc.git/commit - src/lxc/network.c
network: always initialize struct nl_handler
authorAlexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Fri, 9 Dec 2022 17:33:04 +0000 (18:33 +0100)
committerAlexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
Mon, 12 Dec 2022 09:34:18 +0000 (10:34 +0100)
commitf8aa61f97ff4e9c7a4e995981ef386a602ac20a7
tree2b9e38f7215c069256b465c68d26beb21b58b99d
parent6ea4a6c06b1c61ffa495adac6fa92bfb5b96c52e
network: always initialize struct nl_handler

Despite the fact that struct nl_handler is filled zeros
in netlink_open() there are two cases where we have possible
exit paths from the function before netlink_open() is called.

At the same time we have cleaner registered:
call_cleaner(netlink_close)

Two cases:
- netdev_get_flag
- lxc_ipvlan_create

If we are exiting from these functions before netlink_open()
is called we will close random file descriptor by reading
it from (struct nl_handler)->fd.

Let's just properly initialize this structure in all cases
to prevent this bug in the future.

Reported-by: coverity (CID #1517319 and #1517316)
Signed-off-by: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com>
src/lxc/network.c
src/lxc/nl.h