Ryan Salsamendi has uploaded this change for review. ( https://review.coreboot.org/20452
Change subject: cpu/x86/name: Fix undefined behavior ......................................................................
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.
Change-Id: I1362a3eb8c97f5c7e848d75f8d1a219968a7ef9e Signed-off-by: Ryan Salsamendi rsalsamendi@hotmail.com --- M src/cpu/x86/name/name.c 1 file changed, 3 insertions(+), 4 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/52/20452/1
diff --git a/src/cpu/x86/name/name.c b/src/cpu/x86/name/name.c index b59fd8b..aa1ba7a 100644 --- a/src/cpu/x86/name/name.c +++ b/src/cpu/x86/name/name.c @@ -21,9 +21,8 @@ void fill_processor_name(char *processor_name) { struct cpuid_result regs; - char temp_processor_name[49]; char *processor_name_start; - unsigned int *name_as_ints = (unsigned int *)temp_processor_name; + unsigned int name_as_ints[13]; int i;
for (i = 0; i < 3; i++) { @@ -34,10 +33,10 @@ name_as_ints[i * 4 + 3] = regs.edx; }
- temp_processor_name[48] = 0; + name_as_ints[12] = 0;
/* Skip leading spaces. */ - processor_name_start = temp_processor_name; + processor_name_start = (char *)name_as_ints; while (*processor_name_start == ' ') processor_name_start++;