mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
udevadm: check number of passed arguments
We didn't check the number of arguments first, hence ended up outputting some ugly complaints with `(null)` in a format string. And what's worse accepted any number of arguments, where we'd ignore all but the first two though.
This commit is contained in:
committed by
Yu Watanabe
parent
d810815ed4
commit
e5dfe2cd8d
@@ -58,16 +58,11 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
assert_not_reached();
|
assert_not_reached();
|
||||||
}
|
}
|
||||||
|
|
||||||
arg_command = argv[optind++];
|
if (argc != optind + 2)
|
||||||
if (!arg_command)
|
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Expected two arguments: command string and device path.");
|
||||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
|
||||||
"Command missing.");
|
|
||||||
|
|
||||||
arg_syspath = argv[optind++];
|
|
||||||
if (!arg_syspath)
|
|
||||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
|
||||||
"device is missing.");
|
|
||||||
|
|
||||||
|
arg_command = ASSERT_PTR(argv[optind]);
|
||||||
|
arg_syspath = ASSERT_PTR(argv[optind+1]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user