summaryrefslogtreecommitdiff
path: root/ui/cli
diff options
context:
space:
mode:
authorDario Lombardo <lomato@gmail.com>2016-09-09 16:41:15 +0200
committerPeter Wu <peter@lekensteyn.nl>2016-09-15 21:38:43 +0000
commitacb68ae1c461f8608389b130c8e452bda04d40da (patch)
treef5e78e3833ac057b939b42d50c76cad1984caae2 /ui/cli
parent251bc5ca13e375851c4630053693a2460083c68a (diff)
downloadwireshark-acb68ae1c461f8608389b130c8e452bda04d40da.tar.gz
cli: use ws_strtou function.
Change-Id: Ic358c50aa21dac485348ee5f7af8947f75e4f952 Reviewed-on: https://code.wireshark.org/review/17611 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'ui/cli')
-rw-r--r--ui/cli/tap-diameter-avp.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/ui/cli/tap-diameter-avp.c b/ui/cli/tap-diameter-avp.c
index 02106cd9f4..4251c2562c 100644
--- a/ui/cli/tap-diameter-avp.c
+++ b/ui/cli/tap-diameter-avp.c
@@ -42,6 +42,8 @@
#include <glib.h>
+#include <wsutil/strtoi.h>
+
#include <epan/packet_info.h>
#include <epan/tap.h>
#include <epan/epan_dissect.h>
@@ -238,8 +240,16 @@ diameteravp_init(const char *opt_arg, void *userdata _U_)
opt_count = 0;
while (tokens[opt_count])
opt_count++;
- if (opt_count > 2)
- ds->cmd_code = (guint32)atoi(tokens[2]);
+ if (opt_count > 2) {
+ /* if the token is a not-null string and it's not *, the conversion must succeeed */
+ if (strlen(tokens[2]) > 0 && tokens[2][0] != '*') {
+ if (!ws_strtou32(tokens[2], NULL, &ds->cmd_code)) {
+ fprintf(stderr, "Invalid integer token: %s\n", tokens[2]);
+ g_strfreev(tokens);
+ exit(1);
+ }
+ }
+ }
/* Loop over diameter field names. */
for (opt_idx=3; opt_idx<opt_count; opt_idx++)