Use strtoq() instead of strtol() so that large inums, and sizes can be

specified.

Not fixed: specification of large uids and gids; silent truncation of
unrepresentable values.
This commit is contained in:
Bruce Evans 1996-04-07 12:58:13 +00:00
parent ea5256699d
commit 9192bbf46f
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=15102

View File

@ -76,12 +76,12 @@ static PLAN *palloc __P((enum ntype, int (*) __P((PLAN *, FTSENT *))));
* find_parsenum -- * find_parsenum --
* Parse a string of the form [+-]# and return the value. * Parse a string of the form [+-]# and return the value.
*/ */
static long static long long
find_parsenum(plan, option, vp, endch) find_parsenum(plan, option, vp, endch)
PLAN *plan; PLAN *plan;
char *option, *vp, *endch; char *option, *vp, *endch;
{ {
long value; long long value;
char *endchar, *str; /* Pointer to character ending conversion. */ char *endchar, *str; /* Pointer to character ending conversion. */
/* Determine comparison from leading + or -. */ /* Determine comparison from leading + or -. */
@ -101,11 +101,11 @@ find_parsenum(plan, option, vp, endch)
} }
/* /*
* Convert the string with strtol(). Note, if strtol() returns zero * Convert the string with strtoq(). Note, if strtoq() returns zero
* and endchar points to the beginning of the string we know we have * and endchar points to the beginning of the string we know we have
* a syntax error. * a syntax error.
*/ */
value = strtol(str, &endchar, 10); value = strtoq(str, &endchar, 10);
if (value == 0 && endchar == str) if (value == 0 && endchar == str)
errx(1, "%s: %s: illegal numeric value", option, vp); errx(1, "%s: %s: illegal numeric value", option, vp);
if (endchar[0] && (endch == NULL || endchar[0] != *endch)) if (endchar[0] && (endch == NULL || endchar[0] != *endch))