misc-progs: smartctrl: Sanitise device name

Fixes: #12562
Reported-by: Albert Schwarzkopf <ipfire@quitesimple.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Michael Tremer
2021-01-06 11:45:20 +00:00
parent 5efedb5487
commit 14dc1c68f7

View File

@@ -22,6 +22,11 @@ int main(int argc, char *argv[]) {
exit(1);
}
if (!is_valid_argument_alnum(argv[1])) {
fprintf(stderr, "Invalid device name '%s'\n", argv[1]);
exit(2);
}
char command[STRING_SIZE];
snprintf(command, STRING_SIZE, "/var/run/hddshutdown-%s", argv[1]);