]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Linux: Work around a coverity issue
authorRoy Marples <roy@marples.name>
Tue, 23 Jul 2019 14:27:48 +0000 (15:27 +0100)
committerRoy Marples <roy@marples.name>
Tue, 23 Jul 2019 14:27:48 +0000 (15:27 +0100)
sa points to a struct sockaddr inside a union where the
biggest member os sockaddr_in6.
We cast sa to char *, and then write to the address offset
directly which will go beyond a sockaddr if we're writing
a sockaddr_in6 - but this is fine, the union caters for it.

src/if-linux.c

index 729783f80b45ecd504ce94e2811518d7df9a51ad..e3a7947368b2dc673ef3a7226fb666abd4b8eb11 100644 (file)
@@ -494,6 +494,8 @@ if_copyrt(struct dhcpcd_ctx *ctx, struct rt *rt, struct nlmsghdr *nlm)
 
                        sa->sa_family = rtm->rtm_family;
                        salen = sa_addrlen(sa);
+                       /* sa is a union where sockaddr_in6 is the biggest. */
+                       /* coverity[overrun-buffer-arg] */
                        memcpy((char *)sa + sa_addroffset(sa), RTA_DATA(rta),
                            MIN(salen, RTA_PAYLOAD(rta)));
                }