From: Willy Tarreau Date: Thu, 20 Sep 2018 09:39:39 +0000 (+0200) Subject: BUILD: sockpair: silence a build warning at -Wextra X-Git-Tag: v1.9-dev3~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7d7ab43a33f86e39fa3ce232e84235c9ed590445;p=thirdparty%2Fhaproxy.git BUILD: sockpair: silence a build warning at -Wextra 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. --- diff --git a/src/proto_sockpair.c b/src/proto_sockpair.c index 8f4a87462e..bc8557a0d0 100644 --- a/src/proto_sockpair.c +++ b/src/proto_sockpair.c @@ -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);