summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRyan Salsamendi <rsalsamendi@hotmail.com>2017-07-01 18:21:46 -0700
committerNico Huber <nico.h@gmx.de>2017-07-03 17:15:28 +0000
commit312b23522ad8fa76bc6a79cd87e2b327635edb77 (patch)
tree84ab9beac434284faea62c82d6a395e7e4249b5f /src
parentfa0725dead0fdc7e9330e77c42ff4ed4b36a89c4 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/cpu/x86/name/name.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/cpu/x86/name/name.c b/src/cpu/x86/name/name.c
index b59fd8bef9..cff2e5c6ad 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;
+ uint32_t name_as_ints[13];
int 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;
}
- 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++;
- memset(processor_name, 0, 49);
strcpy(processor_name, processor_name_start);
}