summaryrefslogtreecommitdiff
path: root/netsniff-ng.c
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2013-06-12 14:33:43 +0200
committerDaniel Borkmann <dborkman@redhat.com>2013-06-12 14:33:43 +0200
commitdfb45a7ac75d17c3a8421bfb53840d6db271a121 (patch)
tree3d9882f7c077d7ff431a1379f89f2115640ce201 /netsniff-ng.c
parent44b463529a8a9f2ccd1ec2acb8a4dfc117a636cb (diff)
ioops: misc: add dup{,2}_or_die to ioops
Bail out if it should ever fail. Detected by coverty in the translate_pcap_to_txf() path. Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Diffstat (limited to 'netsniff-ng.c')
-rw-r--r--netsniff-ng.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/netsniff-ng.c b/netsniff-ng.c
index 14ce8f2..2738b9a 100644
--- a/netsniff-ng.c
+++ b/netsniff-ng.c
@@ -184,7 +184,7 @@ static void pcap_to_xmit(struct ctx *ctx)
tx_sock = pf_socket();
if (!strncmp("-", ctx->device_in, strlen("-"))) {
- fd = dup(fileno(stdin));
+ fd = dup_or_die(fileno(stdin));
close(fileno(stdin));
if (ctx->pcap == PCAP_OPS_MM)
ctx->pcap = PCAP_OPS_SG;
@@ -544,7 +544,7 @@ static void read_pcap(struct ctx *ctx)
bug_on(!__pcap_io);
if (!strncmp("-", ctx->device_in, strlen("-"))) {
- fd = dup(fileno(stdin));
+ fd = dup_or_die(fileno(stdin));
close(fileno(stdin));
if (ctx->pcap == PCAP_OPS_MM)
ctx->pcap = PCAP_OPS_SG;
@@ -579,7 +579,7 @@ static void read_pcap(struct ctx *ctx)
if (ctx->device_out) {
if (!strncmp("-", ctx->device_out, strlen("-"))) {
- fdo = dup(fileno(stdout));
+ fdo = dup_or_die(fileno(stdout));
close(fileno(stdout));
} else {
fdo = open_or_die_m(ctx->device_out, O_RDWR | O_CREAT |
@@ -769,7 +769,7 @@ static int begin_single_pcap_file(struct ctx *ctx)
bug_on(!__pcap_io);
if (!strncmp("-", ctx->device_out, strlen("-"))) {
- fd = dup(fileno(stdout));
+ fd = dup_or_die(fileno(stdout));
close(fileno(stdout));
if (ctx->pcap == PCAP_OPS_MM)
ctx->pcap = PCAP_OPS_SG;