summaryrefslogtreecommitdiff
path: root/wsutil/clopts_common.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2016-09-07 10:43:15 -0700
committerGuy Harris <guy@alum.mit.edu>2016-09-07 20:41:53 +0000
commitc7fc2802221877d939bb939f04766a5a30cfdb9f (patch)
tree7762d3a9dbf0cd8caffdfed880ce576c3e5cb1cd /wsutil/clopts_common.c
parenta66aa4c9c90017f0c03412b02a2be2b2cef3ac5d (diff)
downloadwireshark-c7fc2802221877d939bb939f04766a5a30cfdb9f.tar.gz
Make the ws_strto* routines more like the strto* routines.
Not all uses of atoi() or various strto* routines in Wireshark expect the string to contain *only* a number, so not all uses should require that the byte after the number be a '\0'. Have the ws_strto* routines take a "pointer a pointer set to point to the character after the number" argument, and have the callers do the appropriate checks of the character after that. This fixes the VMS trace reading code so that it can read those files again. The get_ routines are handed command-line arguments, so they *do* expect the string to contain only a number; have them check to make sure the byte after the number is a '\0'. Change-Id: I46fc1bea7912b9278e385fe38491a0a2ad60d697 Reviewed-on: https://code.wireshark.org/review/17560 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wsutil/clopts_common.c')
-rw-r--r--wsutil/clopts_common.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/wsutil/clopts_common.c b/wsutil/clopts_common.c
index 695559eb02..1967014c82 100644
--- a/wsutil/clopts_common.c
+++ b/wsutil/clopts_common.c
@@ -33,10 +33,11 @@
int
get_natural_int(const char *string, const char *name)
{
+ const char *end;
gint32 number;
- if (!ws_strtoi32(string, &number)) {
- if (errno == EINVAL) {
+ if (!ws_strtoi32(string, &end, &number)) {
+ if (errno == EINVAL || *end != '\0') {
cmdarg_err("The specified %s \"%s\" isn't a decimal number", name, string);
exit(1);
}