tree-wide: add basic validation of --background argument
Check whether the argument of the `--background` option of `systemd-run`, `run0`, `systemd-nspawn`, `systemd-vmspawn`, and `systemd-pty-forward` is either empty or looks like an ANSI color code, and reject invalid values when parsing arguments. We consider a string to look like an ANSI color code if it consists of one or more sequences of ASCII digits separated by semicolons. This permits every valid ANSI color code, and should reject anything that results in garbled output.
This commit is contained in:
+1
-1
@@ -1529,7 +1529,7 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
break;
|
||||
|
||||
case ARG_BACKGROUND:
|
||||
r = free_and_strdup_warn(&arg_background, optarg);
|
||||
r = parse_background_argument(optarg, &arg_background);
|
||||
if (r < 0)
|
||||
return r;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user