tools/x86/kcpuid: Check last token too

Input lines like

  0x8000001E,     0, EAX,   31:0, Extended APIC ID

where the short name is missing lead to a segfault because the loop
takes the long name for the short name and tokens[5] becomes NULL which
explodes later in strcpy().

Check its value too before further processing.

Signed-off-by: Borislav Petkov <bp@suse.de>
Acked-by: Feng Tang <feng.tang@intel.com>
Link: https://lkml.kernel.org/r/20210315125901.30315-1-bp@alien8.de
This commit is contained in:
Borislav Petkov 2021-03-15 13:08:35 +01:00
parent f706bb5920
commit e20f67026b

View file

@ -324,6 +324,8 @@ static int parse_line(char *line)
str = NULL;
}
tokens[5] = strtok(str, "\n");
if (!tokens[5])
goto err_exit;
/* index/main-leaf */
index = strtoull(tokens[0], NULL, 0);