diff options
author | Toni Uhlig <matzeton@googlemail.com> | 2018-07-15 01:36:38 +0200 |
---|---|---|
committer | Toni Uhlig <matzeton@googlemail.com> | 2018-07-15 01:36:38 +0200 |
commit | d3c9dc4d61edd42ed6b22b4908bc97234765b31a (patch) | |
tree | fbb0c5145688b628c421bf63adbcbb9e50925571 /src | |
parent | 7289395b59b2d7b1d0a92c4a45d9956fe391f423 (diff) |
Coverity CID 301768: added socket() error handling
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/pdesc.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/pdesc.c b/src/pdesc.c index 25bd99f..906f35c 100644 --- a/src/pdesc.c +++ b/src/pdesc.c @@ -87,7 +87,9 @@ proxy_desc_t* create_and_insert_proxy_desc(uint16_t id_no, uint16_t icmp_id, addr->sin_addr.s_addr = dst_ip; addr->sin_family = AF_INET; /* Let's just assume success, shall we? */ - if (connect(cur->sock, (struct sockaddr*)addr, sizeof(struct sockaddr_in)) < 0) { + if (cur->sock >= 0 && + connect(cur->sock, (struct sockaddr*)addr, sizeof(struct sockaddr_in)) < 0) + { pt_log(kLog_error, "Connect to %s:%d failed: %s\n", inet_ntoa(*(struct in_addr*)&addr->sin_addr.s_addr) , ntohs(addr->sin_port), strerror(errno)); } } |