Avoid passing negative values to isdigit() on machines with signed chars.
This commit is contained in:
parent
6489fd2148
commit
a2b28f9d9a
@ -499,11 +499,11 @@ getlist(short **list, char *p)
|
|||||||
char *t;
|
char *t;
|
||||||
|
|
||||||
for (t = p + 1; *t; t++) {
|
for (t = p + 1; *t; t++) {
|
||||||
if (!isdigit(*t))
|
if (!isdigit((unsigned char)*t))
|
||||||
errx(1,
|
errx(1,
|
||||||
"option %.1s requires a list of unsigned numbers separated by commas", t);
|
"option %.1s requires a list of unsigned numbers separated by commas", t);
|
||||||
count++;
|
count++;
|
||||||
while (*t && isdigit(*t))
|
while (*t && isdigit((unsigned char)*t))
|
||||||
t++;
|
t++;
|
||||||
if (*t != ',')
|
if (*t != ',')
|
||||||
break;
|
break;
|
||||||
@ -515,7 +515,7 @@ getlist(short **list, char *p)
|
|||||||
(*list)[count++] = atoi(t);
|
(*list)[count++] = atoi(t);
|
||||||
printf("++ %d ", (*list)[count-1]);
|
printf("++ %d ", (*list)[count-1]);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
while (*t && isdigit(*t))
|
while (*t && isdigit((unsigned char)*t))
|
||||||
t++;
|
t++;
|
||||||
if (*t != ',')
|
if (*t != ',')
|
||||||
break;
|
break;
|
||||||
@ -533,7 +533,7 @@ getnum(int *num, char *p, int strict)
|
|||||||
{
|
{
|
||||||
char *t = p;
|
char *t = p;
|
||||||
|
|
||||||
if (!isdigit(*++t)) {
|
if (!isdigit((unsigned char)*++t)) {
|
||||||
if (strict || *t == '-' || *t == '+')
|
if (strict || *t == '-' || *t == '+')
|
||||||
errx(1, "option %.1s requires an unsigned integer", p);
|
errx(1, "option %.1s requires an unsigned integer", p);
|
||||||
*num = 0;
|
*num = 0;
|
||||||
@ -541,7 +541,7 @@ getnum(int *num, char *p, int strict)
|
|||||||
}
|
}
|
||||||
*num = atoi(t);
|
*num = atoi(t);
|
||||||
while (*++t)
|
while (*++t)
|
||||||
if (!isdigit(*t))
|
if (!isdigit((unsigned char)*t))
|
||||||
break;
|
break;
|
||||||
return(--t);
|
return(--t);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user