summaryrefslogtreecommitdiff
path: root/extcap/randpktdump.c
diff options
context:
space:
mode:
authorDario Lombardo <lomato@gmail.com>2016-08-31 10:14:33 +0200
committerDario Lombardo <lomato@gmail.com>2016-09-16 14:21:16 +0000
commitd67c1db3f2b16185d7cff250e098f48d94883f0e (patch)
treef111269e33ea8b0ac29532c18e2ce16762f4f515 /extcap/randpktdump.c
parent2492fe41ba165738aa8667ebfe7f9e96f69ef350 (diff)
downloadwireshark-d67c1db3f2b16185d7cff250e098f48d94883f0e.tar.gz
extcap: make extcap use the ws_strtoi/u functions.
Change-Id: Id75c72eba869c8a0f413ce8b5d6329ce172aed1f Reviewed-on: https://code.wireshark.org/review/17415 Petri-Dish: Dario Lombardo <lomato@gmail.com> Reviewed-by: Roland Knall <rknall@gmail.com> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Dario Lombardo <lomato@gmail.com>
Diffstat (limited to 'extcap/randpktdump.c')
-rw-r--r--extcap/randpktdump.c14
1 files changed, 9 insertions, 5 deletions
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 <wsutil/strtoi.h>
#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: