]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Squash apparent forward-null in clnttcp_create()
authorRobbie Harwood <rharwood@redhat.com>
Fri, 30 Aug 2019 15:16:58 +0000 (11:16 -0400)
committerGreg Hudson <ghudson@mit.edu>
Wed, 11 Sep 2019 16:58:05 +0000 (12:58 -0400)
clnttcp_create() only allows raddr to be NULL if *sockp is set.
Static analyzers cannot know this, so can report a forward null
defect.  Add an raddr check before calling connect() to squash the
defect.

[ghudson@mit.edu: rewrote commit message]

src/lib/rpc/clnt_tcp.c

index 87761906c2695ab31c119faed303793bd4da86e1..dbd62d0a77d6524c8e2f1d35c8dab5593de839aa 100644 (file)
@@ -168,9 +168,9 @@ clnttcp_create(
        if (*sockp < 0) {
                *sockp = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
                (void)bindresvport_sa(*sockp, NULL);
-               if ((*sockp < 0)
-                   || (connect(*sockp, (struct sockaddr *)raddr,
-                   sizeof(*raddr)) < 0)) {
+               if (*sockp < 0 || raddr == NULL ||
+                   connect(*sockp, (struct sockaddr *)raddr,
+                           sizeof(*raddr)) < 0) {
                        rpc_createerr.cf_stat = RPC_SYSTEMERROR;
                        rpc_createerr.cf_error.re_errno = errno;
                         (void)closesocket(*sockp);