diff options
author | Tobias Klauser <tklauser@distanz.ch> | 2013-08-12 22:45:47 +0200 |
---|---|---|
committer | Tobias Klauser <tklauser@distanz.ch> | 2013-08-12 22:45:47 +0200 |
commit | bce6f96faa3fbb50538712436ea2f4771d6491f9 (patch) | |
tree | 1e94f5b24e86a2e82a569250801ec1769d401613 /netsniff-ng.c | |
parent | b5b2d939664183d9d8f3906366faf01655886dfc (diff) |
netsniff-ng: Check return value of poll()
The return value of two calls to poll() are never check, despite the
(unlikely) possibility of them returning an error, fix it by checking
the return value and panic()ing on error.
This issue was discovered using the Coverity scanner.
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'netsniff-ng.c')
-rw-r--r-- | netsniff-ng.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/netsniff-ng.c b/netsniff-ng.c index 0f35d04..682fb39 100644 --- a/netsniff-ng.c +++ b/netsniff-ng.c @@ -343,7 +343,7 @@ static void receive_to_xmit(struct ctx *ctx) { short ifflags = 0; uint8_t *in, *out; - int rx_sock, ifindex_in, ifindex_out; + int rx_sock, ifindex_in, ifindex_out, ret; unsigned int size_in, size_out, it_in = 0, it_out = 0; unsigned long frame_count = 0; struct frame_map *hdr_in, *hdr_out; @@ -473,7 +473,9 @@ static void receive_to_xmit(struct ctx *ctx) goto out; } - poll(&rx_poll, 1, -1); + ret = poll(&rx_poll, 1, -1); + if (unlikely(ret < 0)) + panic("Poll failed!\n"); } out: @@ -982,7 +984,9 @@ static void recv_only_or_dump(struct ctx *ctx) break; } - poll(&rx_poll, 1, -1); + ret = poll(&rx_poll, 1, -1); + if (unlikely(ret < 0)) + panic("Poll failed!\n"); } bug_on(gettimeofday(&end, NULL)); |