summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2014-10-17 18:15:49 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2014-10-17 18:15:49 +0000
commitbbd1ed2e546f7fcef3b41f9a2564d8fce925c1e9 (patch)
treec0b5438e6a36a75a19dd88a71fd38bb9c8843014
parent9f3d7e19f26a48ba0a4b05fe590d4a76077a4ced (diff)
Also remove trailing spaces from the CPU brand string.
ok deraadt@, armani@
-rw-r--r--sys/arch/amd64/amd64/identcpu.c6
-rw-r--r--sys/arch/i386/i386/machdep.c6
2 files changed, 8 insertions, 4 deletions
diff --git a/sys/arch/amd64/amd64/identcpu.c b/sys/arch/amd64/amd64/identcpu.c
index f49c4601df6..ed460790fc8 100644
--- a/sys/arch/amd64/amd64/identcpu.c
+++ b/sys/arch/amd64/amd64/identcpu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: identcpu.c,v 1.55 2014/09/14 14:17:23 jsg Exp $ */
+/* $OpenBSD: identcpu.c,v 1.56 2014/10/17 18:15:48 kettenis Exp $ */
/* $NetBSD: identcpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */
/*
@@ -408,7 +408,7 @@ identifycpu(struct cpu_info *ci)
CPUID(0x80000004, brand[8], brand[9], brand[10], brand[11]);
strlcpy(mycpu_model, (char *)brand, sizeof(mycpu_model));
- /* Remove leading and duplicated spaces from mycpu_model */
+ /* Remove leading, trailing and duplicated spaces from mycpu_model */
brandstr_from = brandstr_to = mycpu_model;
skipspace = 1;
while (*brandstr_from != '\0') {
@@ -420,6 +420,8 @@ identifycpu(struct cpu_info *ci)
skipspace = 1;
brandstr_from++;
}
+ if (skipspace && brandstr_to > mycpu_model)
+ brandstr_to--;
*brandstr_to = '\0';
if (mycpu_model[0] == 0)
diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c
index 4c3c9faf28b..f6f99419ffb 100644
--- a/sys/arch/i386/i386/machdep.c
+++ b/sys/arch/i386/i386/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.552 2014/10/17 01:46:26 dlg Exp $ */
+/* $OpenBSD: machdep.c,v 1.553 2014/10/17 18:15:48 kettenis Exp $ */
/* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */
/*-
@@ -1815,7 +1815,7 @@ identifycpu(struct cpu_info *ci)
}
}
- /* Remove leading and duplicated spaces from cpu_brandstr */
+ /* Remove leading, trailing and duplicated spaces from cpu_brandstr */
brandstr_from = brandstr_to = cpu_brandstr;
skipspace = 1;
while (*brandstr_from != '\0') {
@@ -1827,6 +1827,8 @@ identifycpu(struct cpu_info *ci)
skipspace = 1;
brandstr_from++;
}
+ if (skipspace && brandstr_to > cpu_brandstr)
+ brandstr_to--;
*brandstr_to = '\0';
if (cpu_brandstr[0] == '\0') {