diff options
author | Siddhesh Poyarekar <siddhesh@sourceware.org> | 2021-05-12 16:50:59 +0530 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@sourceware.org> | 2021-05-13 08:05:19 +0530 |
commit | 7eeb05a3958407675d3c4c5351d8ed7738156fbf (patch) | |
tree | 259beaa4d1c847484a73669a91d1b39fd216e72d /inet/rexec.c | |
parent | 900962f37f64c263db83ec8639847e8f6753b8d9 (diff) | |
download | glibc-7eeb05a3958407675d3c4c5351d8ed7738156fbf.tar.gz glibc-7eeb05a3958407675d3c4c5351d8ed7738156fbf.tar.xz glibc-7eeb05a3958407675d3c4c5351d8ed7738156fbf.zip |
inet: Free result from getaddrinfo
Coverity discovered paths where the result from getaddrinfo was not freed.
Diffstat (limited to 'inet/rexec.c')
-rw-r--r-- | inet/rexec.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/inet/rexec.c b/inet/rexec.c index bda536723b..064e979d68 100644 --- a/inet/rexec.c +++ b/inet/rexec.c @@ -76,13 +76,13 @@ rexec_af (char **ahost, int rport, const char *name, const char *pass, ahostbuf = __strdup (res0->ai_canonname); if (ahostbuf == NULL) { perror ("rexec: strdup"); - return (-1); + goto bad2; } *ahost = ahostbuf; } else { *ahost = NULL; __set_errno (ENOENT); - return -1; + goto bad2; } ruserpass(res0->ai_canonname, &name, &pass); retry: @@ -90,7 +90,7 @@ retry: s = __socket(res0->ai_family, res0->ai_socktype, 0); if (s < 0) { perror("rexec: socket"); - return (-1); + goto bad2; } if (__connect(s, res0->ai_addr, res0->ai_addrlen) < 0) { if (errno == ECONNREFUSED && timo <= 16) { @@ -100,7 +100,7 @@ retry: goto retry; } perror(res0->ai_canonname); - return (-1); + goto bad; } if (fd2p == 0) { (void) __write(s, "", 1); @@ -116,10 +116,9 @@ retry: socklen_t sa2len; s2 = __socket(res0->ai_family, res0->ai_socktype, 0); - if (s2 < 0) { - (void) __close(s); - return (-1); - } + if (s2 < 0) + goto bad; + __listen(s2, 1); sa2len = sizeof (sa2); if (__getsockname(s2, &sa2.sa, &sa2len) < 0) { @@ -185,6 +184,7 @@ bad: if (port) (void) __close(*fd2p); (void) __close(s); +bad2: freeaddrinfo(res0); return (-1); } |