summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgwk <gwk@openbsd.org>2007-02-12 19:53:36 +0000
committergwk <gwk@openbsd.org>2007-02-12 19:53:36 +0000
commit8677f8105268feec3003313cdbe20c5a1507ff7b (patch)
treeaac46d5877d5f0ba5229a9145efcb850503b142b
parentfrom FreeBSD via Jung (moorang at gmail), fix obvious typo in __fpu_ftox() (diff)
downloadwireguard-openbsd-8677f8105268feec3003313cdbe20c5a1507ff7b.tar.xz
wireguard-openbsd-8677f8105268feec3003313cdbe20c5a1507ff7b.zip
Fix the hw.vendor/product sysctls on sparc64, handle the cases where
banner-name begins with "SUNW," and make a copy of the platform_type buffer before chopping it up, so other/future users of platform_type dont get a rude shock. deraadt asked for this a 100 million years ago before 4.0. tested by pyr, brad, and kettenis. ok kettenis@
-rw-r--r--sys/arch/sparc64/sparc64/autoconf.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/sys/arch/sparc64/sparc64/autoconf.c b/sys/arch/sparc64/sparc64/autoconf.c
index 2fd2316d9dc..f893839679f 100644
--- a/sys/arch/sparc64/sparc64/autoconf.c
+++ b/sys/arch/sparc64/sparc64/autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.c,v 1.58 2006/11/28 16:56:50 dlg Exp $ */
+/* $OpenBSD: autoconf.c,v 1.59 2007/02/12 19:53:36 gwk Exp $ */
/* $NetBSD: autoconf.c,v 1.51 2001/07/24 19:32:11 eeh Exp $ */
/*
@@ -1024,14 +1024,19 @@ extern bus_space_tag_t mainbus_space_tag;
OF_getprop(findroot(), "name", platform_type,
sizeof(platform_type));
printf(": %s\n", platform_type);
- if (len > 0) {
- hw_vendor = platform_type;
- if ((p = memchr(hw_vendor, ' ', len)) != NULL) {
+
+ hw_vendor = malloc(sizeof(platform_type), M_DEVBUF, M_NOWAIT);
+ if (len > 0 && hw_vendor != NULL) {
+ strlcpy(hw_vendor, platform_type, sizeof(platform_type));
+ if ((strncmp(hw_vendor, "SUNW,", 5)) == 0) {
+ p = hw_prod = hw_vendor + 5;
+ hw_vendor = "Sun";
+ } else if ((p = memchr(hw_vendor, ' ', len)) != NULL) {
*p = '\0';
hw_prod = ++p;
- if ((p = memchr(p, '(', len - (p - hw_vendor))) != NULL)
- *p = '\0';
}
+ if ((p = memchr(hw_prod, '(', len - (p - hw_prod))) != NULL)
+ *p = '\0';
}
/*
@@ -1053,7 +1058,7 @@ extern bus_space_tag_t mainbus_space_tag;
/* the first early device to be configured is the cpu */
{
/* XXX - what to do on multiprocessor machines? */
-
+
for (node = OF_child(node); node; node = OF_peer(node)) {
if (OF_getprop(node, "device_type",
buf, sizeof(buf)) <= 0)