diff options
author | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2006-07-17 20:31:58 +0000 |
---|---|---|
committer | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2006-07-17 20:31:58 +0000 |
commit | 7c958807b0d71b690561bfc1bf251677acd9db68 (patch) | |
tree | d5c7290a8ace81f48c2c3aa13e46945be4f4c5ee /sys/arch/i386 | |
parent | fc4f9b2253667600f39d18b02f3b3b81237b9a6b (diff) |
use malloc'ed buffers rather than losing some/all of the static buffers
and allow for longer strings (as per spec).
mickey@ and gwk@ ok.
Diffstat (limited to 'sys/arch/i386')
-rw-r--r-- | sys/arch/i386/i386/bios.c | 74 |
1 files changed, 51 insertions, 23 deletions
diff --git a/sys/arch/i386/i386/bios.c b/sys/arch/i386/i386/bios.c index 867a99e13f4..7695827ccca 100644 --- a/sys/arch/i386/i386/bios.c +++ b/sys/arch/i386/i386/bios.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bios.c,v 1.65 2006/05/20 22:38:52 deraadt Exp $ */ +/* $OpenBSD: bios.c,v 1.66 2006/07/17 20:31:57 fgsch Exp $ */ /* * Copyright (c) 1997-2001 Michael Shalayeff @@ -746,11 +746,11 @@ fixstring(char *s) void 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) @@ -775,34 +775,62 @@ 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->serial, ser, sizeof(ser))) != - NULL) - hw_serial = 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, 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)) { /* |