From bce6f96faa3fbb50538712436ea2f4771d6491f9 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 12 Aug 2013 22:45:47 +0200 Subject: [PATCH] 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 --- netsniff-ng.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/netsniff-ng.c b/netsniff-ng.c index 0f35d043..682fb39d 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)); -- 2.11.4.GIT