mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zkey: correctly detect abbreviated commands
Abbreviated commands are not recognized and zkey issues an invalid command error. In is_command(), the abbreviated command string is copied into the command_str variable. Because this variable is not initialized and, thus, might contain arbitrary data, a NUL-terminated is not guaranteed. The following string comparison is very likely to fail. Correct this problem by comparing up to the length of the command string only. Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com> Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
This commit is contained in:
committed by
Michael Holzheu
parent
f1a5ab20b7
commit
18f1730b92
@@ -964,7 +964,7 @@ static bool is_command(struct zkey_command *command, const char *str)
|
||||
if (str_len > strlen(command->command))
|
||||
return false;
|
||||
strncpy(command_str, command->command, str_len);
|
||||
if (strcasecmp(str, command_str) != 0)
|
||||
if (strncasecmp(str, command_str, str_len) != 0)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user