forked from osmocom/wireshark
Use ws_strtoi32() in get_natural_int().
Change-Id: I9a95239de8db18cff0f6c62cb526f3ef0cb29f01 Reviewed-on: https://code.wireshark.org/review/17513 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
9ef70fce3c
commit
5eb9170227
|
@ -23,7 +23,9 @@
|
|||
#include "config.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <wsutil/strtoi.h>
|
||||
#include <wsutil/cmdarg_err.h>
|
||||
|
||||
#include <wsutil/clopts_common.h>
|
||||
|
@ -31,11 +33,10 @@
|
|||
int
|
||||
get_natural_int(const char *string, const char *name)
|
||||
{
|
||||
long number;
|
||||
char *p;
|
||||
gint32 number;
|
||||
|
||||
number = strtol(string, &p, 10);
|
||||
if (p == string || *p != '\0') {
|
||||
if (!ws_strtoi32(string, &number)) {
|
||||
if (errno == EINVAL) {
|
||||
cmdarg_err("The specified %s \"%s\" isn't a decimal number", name, string);
|
||||
exit(1);
|
||||
}
|
||||
|
@ -43,9 +44,12 @@ get_natural_int(const char *string, const char *name)
|
|||
cmdarg_err("The specified %s \"%s\" is a negative number", name, string);
|
||||
exit(1);
|
||||
}
|
||||
if (number > INT_MAX) {
|
||||
cmdarg_err("The specified %s \"%s\" is too large (greater than %d)",
|
||||
name, string, INT_MAX);
|
||||
name, string, number);
|
||||
exit(1);
|
||||
}
|
||||
if (number < 0) {
|
||||
cmdarg_err("The specified %s \"%s\" is a negative number", name, string);
|
||||
exit(1);
|
||||
}
|
||||
return (int)number;
|
||||
|
|
Loading…
Reference in New Issue