From: Todd C. Miller Date: Sun, 10 Oct 1999 21:21:22 +0000 (+0000) Subject: use strtol, not strtoul since not everyone has not strtoul X-Git-Tag: SUDO_1_6_0~41 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d34020aef39c09d25ca2665d81b48d406b07d392;p=sudo use strtol, not strtoul since not everyone has not strtoul --- diff --git a/defaults.c b/defaults.c index c10b48b60..bde4823fa 100644 --- a/defaults.c +++ b/defaults.c @@ -547,16 +547,16 @@ store_int(val, def, op) int op; { char *endp; - unsigned long ul; + long l; if (op == FALSE) { def->sd_un.ival = 0; } else { - ul = strtoul(val, &endp, 10); - if (*endp != '\0') + l = strtol(val, &endp, 10); + if (*endp != '\0' || l < 0) return(FALSE); - /* XXX - should check against UINT_MAX */ - def->sd_un.ival = (unsigned int)ul; + /* XXX - should check against INT_MAX */ + def->sd_un.ival = (unsigned int)l; } return(TRUE); } @@ -642,15 +642,15 @@ store_mode(val, def, op) int op; { char *endp; - unsigned long ul; + long l; if (op == FALSE) { def->sd_un.mode = 0777; } else { - ul = strtoul(val, &endp, 8); - if (*endp != '\0' || ul >= 0777) + l = strtol(val, &endp, 8); + if (*endp != '\0' || l < 0 || l >= 0777) return(FALSE); - def->sd_un.mode = (mode_t)ul; + def->sd_un.mode = (mode_t)l; } return(TRUE); }