]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: sockpair: silence a build warning at -Wextra
authorWilly Tarreau <w@1wt.eu>
Thu, 20 Sep 2018 09:39:39 +0000 (11:39 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 20 Sep 2018 09:42:15 +0000 (11:42 +0200)
An invalid null-deref warning is emitted because cmsg is not checked,
though it definitely is valid given the test performed 10 lines above,
but the compiler cannot necessarily guess this. Adding a null test to
the problematic condition is enough to get rid of it and cheap enough.

src/proto_sockpair.c

index 8f4a87462e03b6eb227fc6146acc2766c4728b2e..bc8557a0d0b2302cc0fd5a63da484a428328b565 100644 (file)
@@ -382,7 +382,7 @@ int recv_fd_uxst(int sock)
                return ret;
 
        cmsg = CMSG_FIRSTHDR(&msghdr);
-       if (cmsg->cmsg_level == SOL_SOCKET &&
+       if (cmsg && cmsg->cmsg_level == SOL_SOCKET &&
            cmsg->cmsg_type == SCM_RIGHTS) {
                size_t totlen = cmsg->cmsg_len -
                        CMSG_LEN(0);