udevadm-control: reject oversized children-max
The --children-max= option parsed into an unsigned value and then stored it in an int sentinel field. Values above INT_MAX could wrap negative and make the command look as if no control option had been specified. Reject oversized values before assigning the parsed value. Reproducer: $ udevadm control --children-max=2147483648 No control command option is specified. $ echo $? 1 The value should be rejected as out of range instead of being wrapped into the unset sentinel value.
This commit is contained in:
@@ -125,6 +125,9 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
r = safe_atou(opts.arg, &i);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to parse maximum number of children '%s': %m", opts.arg);
|
||||
if (i > INT_MAX)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ERANGE),
|
||||
"Maximum number of children is too large: %s", opts.arg);
|
||||
arg_max_children = i;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ udevadm control -l notice
|
||||
udevadm control --log-level info
|
||||
udevadm control --log-level debug
|
||||
(! udevadm control -l hello)
|
||||
(! udevadm control -m 2147483648)
|
||||
|
||||
# Check if processing queued events has been stopped.
|
||||
udevadm control --stop-exec-queue
|
||||
|
||||
Reference in New Issue
Block a user