mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-31 14:25:15 +00:00
Use sudo_strtonum() instead of strtoull().
Fixes building on systems that lack strtoull(). While dev_t is unsigned on most systems, we can still use sudo_strtonum() here as long as we allow the full range of values [LLONG_MIN,LLONG_MAX]. We don't use strtoul() here since some 32-bit systems have 64-bit dev_t.
This commit is contained in:
@@ -466,18 +466,19 @@ sudoers_policy_deserialize_info(struct sudoers_context *ctx, void *v,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MATCHES(*cur, "ttydev=")) {
|
if (MATCHES(*cur, "ttydev=")) {
|
||||||
unsigned long long ullval;
|
long long llval;
|
||||||
char *ep;
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* dev_t is unsigned but sudo_strtonum() deals with signed values.
|
||||||
|
* This is not a problem in practice since we allow the full range.
|
||||||
|
*/
|
||||||
p = *cur + sizeof("ttydev=") - 1;
|
p = *cur + sizeof("ttydev=") - 1;
|
||||||
errno = 0;
|
llval = sudo_strtonum(p, LLONG_MIN, LLONG_MAX, &errstr);
|
||||||
ullval = strtoull(p, &ep, 10);
|
if (errstr != NULL) {
|
||||||
if ((*p == '\0' || *ep != '\0') ||
|
|
||||||
(errno == ERANGE && ullval == ULLONG_MAX)) {
|
|
||||||
INVALID("ttydev=");
|
INVALID("ttydev=");
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
ctx->user.ttydev = (dev_t)ullval;
|
ctx->user.ttydev = (dev_t)llval;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (MATCHES(*cur, "host=")) {
|
if (MATCHES(*cur, "host=")) {
|
||||||
|
Reference in New Issue
Block a user