cpu/x86/name: Fix undefined behavior
Fixes report found by undefined behavior sanitizer. Dereferencing a pointer that's not aligned to the size of access is undefined behavior. Remove unnecessary memset(). Change-Id: I1362a3eb8c97f5c7e848d75f8d1a219968a7ef9e Signed-off-by: Ryan Salsamendi <rsalsamendi@hotmail.com> Reviewed-on: https://review.coreboot.org/20452 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
This commit is contained in:
parent
fa0725dead
commit
312b23522a
1 changed files with 3 additions and 5 deletions
|
@ -21,9 +21,8 @@
|
||||||
void fill_processor_name(char *processor_name)
|
void fill_processor_name(char *processor_name)
|
||||||
{
|
{
|
||||||
struct cpuid_result regs;
|
struct cpuid_result regs;
|
||||||
char temp_processor_name[49];
|
|
||||||
char *processor_name_start;
|
char *processor_name_start;
|
||||||
unsigned int *name_as_ints = (unsigned int *)temp_processor_name;
|
uint32_t name_as_ints[13];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
|
@ -34,13 +33,12 @@ void fill_processor_name(char *processor_name)
|
||||||
name_as_ints[i * 4 + 3] = regs.edx;
|
name_as_ints[i * 4 + 3] = regs.edx;
|
||||||
}
|
}
|
||||||
|
|
||||||
temp_processor_name[48] = 0;
|
name_as_ints[12] = 0;
|
||||||
|
|
||||||
/* Skip leading spaces. */
|
/* Skip leading spaces. */
|
||||||
processor_name_start = temp_processor_name;
|
processor_name_start = (char *)name_as_ints;
|
||||||
while (*processor_name_start == ' ')
|
while (*processor_name_start == ' ')
|
||||||
processor_name_start++;
|
processor_name_start++;
|
||||||
|
|
||||||
memset(processor_name, 0, 49);
|
|
||||||
strcpy(processor_name, processor_name_start);
|
strcpy(processor_name, processor_name_start);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue