From 5887d3d5f9fab689a8a3a6a5fef81b153a10acc7 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 6 Jan 2004 02:58:20 +0000 Subject: [PATCH] Add some sanity checking for the "-i" argument. svn path=/trunk/; revision=9573 --- text2pcap.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/text2pcap.c b/text2pcap.c index b7cb2cef77..97c153803b 100644 --- a/text2pcap.c +++ b/text2pcap.c @@ -6,7 +6,7 @@ * * (c) Copyright 2001 Ashok Narayanan * - * $Id: text2pcap.c,v 1.28 2004/01/05 19:31:44 ulfl Exp $ + * $Id: text2pcap.c,v 1.29 2004/01/06 02:58:20 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -125,7 +125,7 @@ static unsigned long hdr_ethernet_proto = 0; /* Dummy IP header */ static int hdr_ip = FALSE; -static unsigned long hdr_ip_proto = 0; +static long hdr_ip_proto = 0; /* Dummy UDP header */ static int hdr_udp = FALSE; @@ -1077,7 +1077,9 @@ parse_options (int argc, char *argv[]) case 'i': hdr_ip = TRUE; - if (sscanf(optarg, "%ld", &hdr_ip_proto) < 1) { + hdr_ip_proto = strtol(optarg, &p, 10); + if (p == optarg || *p != '\0' || hdr_ip_proto < 0 || + hdr_ip_proto > 255) { fprintf(stderr, "Bad argument for '-i': %s\n", optarg); help(argv[0]); }