summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortobias <tobias@openbsd.org>2014-06-25 18:21:24 +0000
committertobias <tobias@openbsd.org>2014-06-25 18:21:24 +0000
commit6ea8b240a4c07c78390b4b6ff531820d051389f7 (patch)
treefb319c59fd4c5743bd01fae1f72e91f8d2f753c0
parentAT_BASE returns us the *address* of the start of ld.so, so (diff)
downloadwireguard-openbsd-6ea8b240a4c07c78390b4b6ff531820d051389f7.tar.xz
wireguard-openbsd-6ea8b240a4c07c78390b4b6ff531820d051389f7.zip
Check malloc return value for NULL.
ok jsing@
-rw-r--r--usr.sbin/installboot/i386_installboot.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/usr.sbin/installboot/i386_installboot.c b/usr.sbin/installboot/i386_installboot.c
index ad1d65c4ff0..d75793e283b 100644
--- a/usr.sbin/installboot/i386_installboot.c
+++ b/usr.sbin/installboot/i386_installboot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: i386_installboot.c,v 1.3 2014/06/09 15:50:08 jsing Exp $ */
+/* $OpenBSD: i386_installboot.c,v 1.4 2014/06/25 18:21:24 tobias Exp $ */
/* $NetBSD: installboot.c,v 1.5 1995/11/17 23:23:50 gwr Exp $ */
/*
@@ -230,7 +230,8 @@ again:
(mbroff == DOSBBSECTOR) ? "master" : "extended",
(mbroff == DOSBBSECTOR) ? 'M' : 'E', mbroff);
- secbuf = malloc(dl->d_secsize);
+ if ((secbuf = malloc(dl->d_secsize)) == NULL)
+ err(1, NULL);
if (lseek(devfd, (off_t)mbroff * dl->d_secsize, SEEK_SET) < 0 ||
read(devfd, secbuf, dl->d_secsize) < (ssize_t)sizeof(mbr))
err(4, "can't read boot record");