From d67c1db3f2b16185d7cff250e098f48d94883f0e Mon Sep 17 00:00:00 2001 From: Dario Lombardo Date: Wed, 31 Aug 2016 10:14:33 +0200 Subject: extcap: make extcap use the ws_strtoi/u functions. Change-Id: Id75c72eba869c8a0f413ce8b5d6329ce172aed1f Reviewed-on: https://code.wireshark.org/review/17415 Petri-Dish: Dario Lombardo Reviewed-by: Roland Knall Reviewed-by: Peter Wu Tested-by: Petri Dish Buildbot Reviewed-by: Dario Lombardo --- extcap/randpktdump.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'extcap/randpktdump.c') diff --git a/extcap/randpktdump.c b/extcap/randpktdump.c index 974f7f3947..16e4edec09 100644 --- a/extcap/randpktdump.c +++ b/extcap/randpktdump.c @@ -27,6 +27,7 @@ #include "extcap-base.h" #include "randpkt_core/randpkt_core.h" +#include #define RANDPKT_EXTCAP_INTERFACE "randpkt" #define RANDPKTDUMP_VERSION_MAJOR "0" @@ -126,7 +127,7 @@ int main(int argc, char *argv[]) { int option_idx = 0; int result; - int maxbytes = 5000; + guint16 maxbytes = 5000; guint64 count = 1000; int random_type = FALSE; int all_random = FALSE; @@ -192,15 +193,18 @@ int main(int argc, char *argv[]) goto end; case OPT_MAXBYTES: - maxbytes = atoi(optarg); - if (maxbytes > MAXBYTES_LIMIT) { - g_warning("randpktdump: Max bytes is %d", MAXBYTES_LIMIT); + if (!ws_strtou16(optarg, NULL, &maxbytes)) { + g_warning("Invalid parameter maxbytes: %s (max value is %u)", + optarg, G_MAXUINT16); goto end; } break; case OPT_COUNT: - count = g_ascii_strtoull(optarg, NULL, 10); + if (!ws_strtou64(optarg, NULL, &count)) { + g_warning("Invalid packet count: %s", optarg); + goto end; + } break; case OPT_RANDOM_TYPE: -- cgit v1.2.1