diff options
author | 2006-07-17 23:45:11 +0000 | |
---|---|---|
committer | 2006-07-17 23:45:11 +0000 | |
commit | 4025efc2097fa652a0369f5816717e60c0941e17 (patch) | |
tree | 5f560f1ccda939909082e50f03b0241a20986410 | |
parent | same fix as i386 (diff) | |
download | wireguard-openbsd-4025efc2097fa652a0369f5816717e60c0941e17.tar.xz wireguard-openbsd-4025efc2097fa652a0369f5816717e60c0941e17.zip |
same changes as i386. tested by kettenis@ and ckuethe@. thanks.
-rw-r--r-- | sys/arch/amd64/amd64/bios.c | 74 |
1 files changed, 50 insertions, 24 deletions
diff --git a/sys/arch/amd64/amd64/bios.c b/sys/arch/amd64/amd64/bios.c index 63090800f13..7b239746d23 100644 --- a/sys/arch/amd64/amd64/bios.c +++ b/sys/arch/amd64/amd64/bios.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bios.c,v 1.8 2006/05/19 04:49:17 gwk Exp $ */ +/* $OpenBSD: bios.c,v 1.9 2006/07/17 23:45:11 fgsch Exp $ */ /* * Copyright (c) 2006 Gordon Willem Klok <gklok@cogeco.ca> * @@ -240,13 +240,13 @@ fixstring(char *s) } void -smbios_info(char* str) +smbios_info(char * str) { - static char vend[40], prod[30], ver[30], ser[20]; + char *sminfop, sminfo[64]; struct smbtable stbl, btbl; struct smbios_sys *sys; struct smbios_board *board; - int i, uuidf, havebb; + int i, infolen, uuidf, havebb; char *p; if (smbios_entry.mjr < 2) @@ -271,35 +271,61 @@ smbios_info(char* str) * perhaps naieve belief that motherboard vendors will supply this * information. */ - if ((p = smbios_get_string(&stbl, sys->vendor, vend, sizeof(vend))) != - NULL) - hw_vendor = fixstring(p); - if (hw_vendor == NULL) { + sminfop = NULL; + if ((p = smbios_get_string(&stbl, sys->vendor, sminfo, + sizeof(sminfo))) != NULL) + sminfop = fixstring(p); + if (sminfop == NULL) { if (havebb) { - if ((p = smbios_get_string(&btbl, board->vendor, vend, - sizeof(vend))) != NULL) - hw_vendor = fixstring(p); + if ((p = smbios_get_string(&btbl, board->vendor, + sminfo, sizeof(sminfo))) != NULL) + sminfop = fixstring(p); } } - if ((p = smbios_get_string(&stbl, sys->product, prod, sizeof(prod))) != - NULL) - hw_prod = fixstring(p); - if (hw_prod == NULL) { + if (sminfop) { + infolen = strlen(sminfop) + 1; + hw_vendor = malloc(infolen, M_DEVBUF, M_NOWAIT); + if (hw_vendor) + strlcpy(hw_vendor, sminfop, infolen); + sminfop = NULL; + } + if ((p = smbios_get_string(&stbl, sys->product, sminfo, + sizeof(sminfo))) != NULL) + sminfop = fixstring(p); + if (sminfop == NULL) { if (havebb) { - if ((p = smbios_get_string(&btbl, board->product, prod, - sizeof(prod))) != NULL) - hw_prod = fixstring(p); + if ((p = smbios_get_string(&btbl, board->product, + sminfo, sizeof(sminfo))) != NULL) + sminfop = fixstring(p); } } + if (sminfop) { + infolen = strlen(sminfop) + 1; + hw_prod = malloc(infolen, M_DEVBUF, M_NOWAIT); + if (hw_prod) + strlcpy(hw_prod, sminfop, infolen); + sminfop = NULL; + } if (hw_vendor != NULL && hw_prod != NULL) printf("\n%s: %s %s", str, hw_vendor, hw_prod); - if ((p = smbios_get_string(&stbl, sys->version, ver, sizeof(ver))) != - NULL) { - hw_ver = fixstring(p); + if ((p = smbios_get_string(&stbl, sys->version, sminfo, + sizeof(sminfo))) != NULL) + sminfop = fixstring(p); + if (sminfop) { + infolen = strlen(sminfop) + 1; + hw_ver = malloc(infolen, M_DEVBUF, M_NOWAIT); + if (hw_ver) + strlcpy(hw_ver, sminfop, infolen); + sminfop = NULL; } - if ((p = smbios_get_string(&stbl, sys->serial, ser, sizeof(ser))) != - NULL) { - hw_serial = fixstring(p); + if ((p = smbios_get_string(&stbl, sys->serial, sminfo, + sizeof(sminfo))) != NULL) + sminfop = fixstring(p); + if (sminfop) { + infolen = strlen(sminfop) + 1; + hw_serial = malloc(infolen, M_DEVBUF, M_NOWAIT); + if (hw_serial) + strlcpy(hw_serial, sminfop, infolen); } if (smbios_entry.mjr > 2 || (smbios_entry.mjr == 2 && smbios_entry.min >= 1)) { |