diff options
author | Guy Harris <guy@alum.mit.edu> | 2004-01-06 02:58:20 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2004-01-06 02:58:20 +0000 |
commit | 5887d3d5f9fab689a8a3a6a5fef81b153a10acc7 (patch) | |
tree | 5ab8a77e5c04e4380ee09c5358511ca0ce853866 /text2pcap.c | |
parent | c5632f3648fefbe160bf557e1b6b3865a2cbac6b (diff) |
Add some sanity checking for the "-i" argument.
svn path=/trunk/; revision=9573
Diffstat (limited to 'text2pcap.c')
-rw-r--r-- | text2pcap.c | 8 |
1 files 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 <ashokn@cisco.com> * - * $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 <gerald@ethereal.com> @@ -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]); } |