aboutsummaryrefslogtreecommitdiffstats
path: root/dumpcap.c
diff options
context:
space:
mode:
authorHadriel Kaplan <hadrielk@yahoo.com>2014-02-25 11:25:47 -0500
committerEvan Huus <eapache@gmail.com>2014-02-27 17:57:02 +0000
commitc875dc8597a6ff3a513cd6b8397626c331564f5e (patch)
treedb8d463a58d281291b6825e56fe6495dce55d199 /dumpcap.c
parent1828c34519ac16255cbd003cdceded51ef8b789f (diff)
Fix dumpcap.c: Assigned value is garbage or undefined (clang analyzer)
Change-Id: I61dbf5e1e206b1c0d2e594bfba38e83e51e8f09c Reviewed-on: https://code.wireshark.org/review/371 Reviewed-by: Evan Huus <eapache@gmail.com> Tested-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'dumpcap.c')
-rw-r--r--dumpcap.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/dumpcap.c b/dumpcap.c
index ca282986ea..de7536cc0d 100644
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -1968,7 +1968,7 @@ cap_pipe_open_live(char *pipename,
wchar_t *err_str;
#endif
ssize_t b;
- int fd, sel_ret;
+ int fd = -1, sel_ret;
size_t bytes_read;
guint32 magic = 0;
@@ -2146,6 +2146,11 @@ cap_pipe_open_live(char *pipename,
/* read the pcap header */
bytes_read = 0;
while (bytes_read < sizeof magic) {
+ if (fd == -1) {
+ g_snprintf(errmsg, errmsgl, "Invalid file descriptor");
+ goto error;
+ }
+
sel_ret = cap_pipe_select(fd);
if (sel_ret < 0) {
g_snprintf(errmsg, errmsgl,