use strtol, not strtoul since not everyone has not strtoul

This commit is contained in:
Todd C. Miller
1999-10-10 21:21:22 +00:00
parent 315335247e
commit d34020aef3

View File

@@ -547,16 +547,16 @@ store_int(val, def, op)
int op; int op;
{ {
char *endp; char *endp;
unsigned long ul; long l;
if (op == FALSE) { if (op == FALSE) {
def->sd_un.ival = 0; def->sd_un.ival = 0;
} else { } else {
ul = strtoul(val, &endp, 10); l = strtol(val, &endp, 10);
if (*endp != '\0') if (*endp != '\0' || l < 0)
return(FALSE); return(FALSE);
/* XXX - should check against UINT_MAX */ /* XXX - should check against INT_MAX */
def->sd_un.ival = (unsigned int)ul; def->sd_un.ival = (unsigned int)l;
} }
return(TRUE); return(TRUE);
} }
@@ -642,15 +642,15 @@ store_mode(val, def, op)
int op; int op;
{ {
char *endp; char *endp;
unsigned long ul; long l;
if (op == FALSE) { if (op == FALSE) {
def->sd_un.mode = 0777; def->sd_un.mode = 0777;
} else { } else {
ul = strtoul(val, &endp, 8); l = strtol(val, &endp, 8);
if (*endp != '\0' || ul >= 0777) if (*endp != '\0' || l < 0 || l >= 0777)
return(FALSE); return(FALSE);
def->sd_un.mode = (mode_t)ul; def->sd_un.mode = (mode_t)l;
} }
return(TRUE); return(TRUE);
} }