]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udevadm-control: reject oversized children-max
authordongshengyuan <545258830@qq.com>
Fri, 10 Jul 2026 08:08:07 +0000 (16:08 +0800)
committerdongshengyuan <545258830@qq.com>
Fri, 10 Jul 2026 08:08:07 +0000 (16:08 +0800)
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.

src/udev/udevadm-control.c
test/units/TEST-17-UDEV.sanity-check.sh

index 0a0bb35fb5dd563ff8f5cbbaf52d578aad3b14cd..cef3ec7fd564ecb226f5187a014519c9dee09ae0 100644 (file)
@@ -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;
                 }
index 6246638fc941e49f12e2479fd70d763de98ea4b2..18326c03ad8f45acaf791edee3f0cda75ced2142 100755 (executable)
@@ -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