aboutsummaryrefslogtreecommitdiff
path: root/pcap-rpcap.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2017-10-07 12:25:49 -0700
committerGuy Harris <guy@alum.mit.edu>2017-10-07 12:25:49 -0700
commit3df5c4d3d854ce8c9ad733bc9c018e056fb93404 (patch)
tree4eb9ace749dd6d38cc2aaa8c6576632fe51af5b9 /pcap-rpcap.c
parentd89f4a83799ba39fc03c653e1a65915ae5461104 (diff)
Only go to error if we have a control socket.
If we don't have a control socket, just free up the address list, close the pcap_t, and return. Fixes Coverity CID 1419021. Also, don't initialize the control socket; that lets compilers (and other tools) doing dataflow analysis catch cases where we haven't set the socket before using it.
Diffstat (limited to 'pcap-rpcap.c')
-rw-r--r--pcap-rpcap.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/pcap-rpcap.c b/pcap-rpcap.c
index 3f5076c7..09ac5000 100644
--- a/pcap-rpcap.c
+++ b/pcap-rpcap.c
@@ -1919,7 +1919,7 @@ pcap_t *pcap_open_rpcap(const char *source, int snaplen, int flags, int read_tim
/* socket-related variables */
struct addrinfo hints; /* temp, needed to open a socket connection */
struct addrinfo *addrinfo; /* temp, needed to open a socket connection */
- SOCKET sockctrl = 0; /* socket descriptor of the control connection */
+ SOCKET sockctrl; /* socket descriptor of the control connection */
/* RPCAP-related variables */
struct rpcap_header header; /* header of the RPCAP packet */
@@ -2024,7 +2024,11 @@ pcap_t *pcap_open_rpcap(const char *source, int snaplen, int flags, int read_tim
}
if ((sockctrl = sock_open(addrinfo, SOCKOPEN_CLIENT, 0, errbuf, PCAP_ERRBUF_SIZE)) == INVALID_SOCKET)
- goto error;
+ {
+ freeaddrinfo(addrinfo);
+ pcap_close(fp);
+ return NULL;
+ }
freeaddrinfo(addrinfo);
addrinfo = NULL;