From dfb45a7ac75d17c3a8421bfb53840d6db271a121 Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Wed, 12 Jun 2013 14:33:43 +0200 Subject: 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 --- netsniff-ng.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'netsniff-ng.c') 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; -- cgit v1.2.3-54-g00ecf