]> git.proxmox.com Git - mirror_frr.git/commit - zebra/if_netlink.c
zebra: Modify netlink_request to statisfy coverity
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 15 Apr 2020 12:56:03 +0000 (08:56 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 15 Apr 2020 13:01:56 +0000 (09:01 -0400)
commitfd3f8e52b673bbf695ded218d3f566826fa1ce3f
treee02df9aca270a1726f51b05e2a9e59992fd52b49
parent260616d55d96fab302c678ee78e0a58ca60b0aa1
zebra: Modify netlink_request to statisfy coverity

The netlink_request function takes a `struct nlmsghdr *`
pointer from a common pattern that we use:

struct {
struct nlmsghdr n;
struct fib_rule_hdr frh;
char buf[NL_PKT_BUF_SIZE];
} req;

We were calling it `netlink_request(Socket, &req.n)`

The problem here is that coverity, rightly so, sees that
we access the data after the nlmsghdr in netlink_request and
tells us we have an read beyond end of the structure.  While
we know we haven't mangled anything up here because of manual
inspection coverity doesn't have this knowledge implicitly.

So let's modify the code call to netlink_request to pass in the
void pointer of the req structure itself, cast to the appropriate
data structure in the function and do the right thing.  Hopefully
the coverity SA will be happy and we can move on with our life.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
zebra/if_netlink.c
zebra/kernel_netlink.c
zebra/kernel_netlink.h
zebra/rt_netlink.c
zebra/rule_netlink.c