summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2019-07-24 04:04:45 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2019-07-24 04:04:45 +0000
commit481b2281ea37fd63f87e132cf818a0987927ec6b (patch)
treecf287b09cbfb34ff468146efd471c9ba94e95b08 /sys
parent634dab41494c2549ea4d0c29e067897681977cad (diff)
Avoid strlcpy() and printing of bios date if fixstring() returns NULL.
jan@ has a machine where the smbios date is ten space characters which results in fixstring() returning NULL causing a NULL derefence. Reported, tested by and ok jan@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/amd64/amd64/bios.c13
-rw-r--r--sys/arch/i386/i386/bios.c14
2 files changed, 18 insertions, 9 deletions
diff --git a/sys/arch/amd64/amd64/bios.c b/sys/arch/amd64/amd64/bios.c
index 1e395891d6b..92a089e9c81 100644
--- a/sys/arch/amd64/amd64/bios.c
+++ b/sys/arch/amd64/amd64/bios.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bios.c,v 1.38 2019/07/15 00:35:10 jsg Exp $ */
+/* $OpenBSD: bios.c,v 1.39 2019/07/24 04:04:44 jsg Exp $ */
/*
* Copyright (c) 2006 Gordon Willem Klok <gklok@cogeco.ca>
*
@@ -92,6 +92,7 @@ bios_attach(struct device *parent, struct device *self, void *aux)
u_int8_t *p;
int smbiosrev = 0;
struct smbhdr *hdr = NULL;
+ char *sminfop;
if (bios_efiinfo != NULL && bios_efiinfo->config_smbios != 0)
hdr = smbios_find(PMAP_DIRECT_MAP(
@@ -144,9 +145,13 @@ bios_attach(struct device *parent, struct device *self, void *aux)
fixstring(scratch));
if ((smbios_get_string(&bios, sb->release,
scratch, sizeof(scratch))) != NULL) {
- strlcpy(smbios_bios_date, fixstring(scratch),
- sizeof(smbios_bios_date));
- printf(" date %s", fixstring(scratch));
+ sminfop = fixstring(scratch);
+ if (sminfop != NULL) {
+ strlcpy(smbios_bios_date,
+ sminfop,
+ sizeof(smbios_bios_date));
+ printf(" date %s", sminfop);
+ }
}
}
diff --git a/sys/arch/i386/i386/bios.c b/sys/arch/i386/i386/bios.c
index f9f05cf89a5..bf396390131 100644
--- a/sys/arch/i386/i386/bios.c
+++ b/sys/arch/i386/i386/bios.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bios.c,v 1.121 2019/07/15 00:35:10 jsg Exp $ */
+/* $OpenBSD: bios.c,v 1.122 2019/07/24 04:04:44 jsg Exp $ */
/*
* Copyright (c) 1997-2001 Michael Shalayeff
@@ -245,6 +245,7 @@ biosattach(struct device *parent, struct device *self, void *aux)
for (va = ISA_HOLE_VADDR(SMBIOS_START);
va < (u_int8_t *)ISA_HOLE_VADDR(SMBIOS_END); va+= 16) {
struct smbhdr *sh = (struct smbhdr *)va;
+ char *sminfop;
u_int8_t chksum;
vaddr_t eva;
paddr_t pa, end;
@@ -308,10 +309,13 @@ biosattach(struct device *parent, struct device *self, void *aux)
fixstring(scratch));
if ((smbios_get_string(&bios, sb->release,
scratch, sizeof(scratch))) != NULL) {
- strlcpy(smbios_bios_date,
- fixstring(scratch),
- sizeof(smbios_bios_date));
- printf(" date %s", fixstring(scratch));
+ sminfop = fixstring(scratch);
+ if (sminfop != NULL) {
+ strlcpy(smbios_bios_date,
+ sminfop,
+ sizeof(smbios_bios_date));
+ printf(" date %s", sminfop);
+ }
}
}
smbios_info(sc->sc_dev.dv_xname);