summaryrefslogtreecommitdiffstats
path: root/zebra/kernel_netlink.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2020-04-15 14:56:03 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2020-04-15 15:01:56 +0200
commitfd3f8e52b673bbf695ded218d3f566826fa1ce3f (patch)
treee02df9aca270a1726f51b05e2a9e59992fd52b49 /zebra/kernel_netlink.c
parentMerge pull request #6154 from donaldsharp/check_interface_working (diff)
downloadfrr-fd3f8e52b673bbf695ded218d3f566826fa1ce3f.tar.xz
frr-fd3f8e52b673bbf695ded218d3f566826fa1ce3f.zip
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>
Diffstat (limited to 'zebra/kernel_netlink.c')
-rw-r--r--zebra/kernel_netlink.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/zebra/kernel_netlink.c b/zebra/kernel_netlink.c
index 97b023836..a1f7014ce 100644
--- a/zebra/kernel_netlink.c
+++ b/zebra/kernel_netlink.c
@@ -1061,10 +1061,11 @@ int netlink_talk(int (*filter)(struct nlmsghdr *, ns_id_t, int startup),
/* Issue request message to kernel via netlink socket. GET messages
* are issued through this interface.
*/
-int netlink_request(struct nlsock *nl, struct nlmsghdr *n)
+int netlink_request(struct nlsock *nl, void *req)
{
int ret;
struct sockaddr_nl snl;
+ struct nlmsghdr *n = (struct nlmsghdr *)req;
/* Check netlink socket. */
if (nl->sock < 0) {
@@ -1082,7 +1083,7 @@ int netlink_request(struct nlsock *nl, struct nlmsghdr *n)
/* Raise capabilities and send message, then lower capabilities. */
frr_with_privs(&zserv_privs) {
- ret = sendto(nl->sock, (void *)n, n->nlmsg_len, 0,
+ ret = sendto(nl->sock, req, n->nlmsg_len, 0,
(struct sockaddr *)&snl, sizeof(snl));
}