diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2013-06-12 12:31:16 +0200 |
---|---|---|
committer | Daniel Borkmann <dborkman@redhat.com> | 2013-06-12 12:31:16 +0200 |
commit | 4ee9acd587161df26332fc1e07027b1b527e8100 (patch) | |
tree | f21556927896002cb20375e55a671161eb5db2fd /stun.c | |
parent | 93e7cdadf9ddc619c1936303302d4edd50496204 (diff) |
stun: close socket before returning in error case
Do not leak the socket resource when bailing out in error case.
Found by the coverty scanner.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Diffstat (limited to 'stun.c')
-rw-r--r-- | stun.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -100,7 +100,7 @@ static int stun_test(const char *server_ip, int server_port, sizeof(daddr)); if (ret != len) { printf("Error sending request (%s)!\n", strerror(errno)); - return -EIO; + goto close_error; } timeout.tv_sec = TIMEOUT / 1000; @@ -112,7 +112,7 @@ static int stun_test(const char *server_ip, int server_port, ret = select(sock + 1, &fdset, NULL, NULL, &timeout); if (ret <= 0) { printf("STUN server timeout!\n"); - return -EIO; + goto close_error; } memset(rpkt, 0, sizeof(rpkt)); @@ -166,6 +166,9 @@ next: } return 0; +close_error: + close(sock); + return -EIO; } int print_stun_probe(char *server, int sport, int tport) |