summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2015-12-17 20:42:05 +0000
committerjhb <jhb@FreeBSD.org>2015-12-17 20:42:05 +0000
commitfbc3fb8fca4a0344d23fe234e0ffafc009d12547 (patch)
tree31a1990649f0990c39bfa1fdb38c488d5ed51ec9 /usr.sbin
parent4ef184b756b083683d4bac92ab02330aa08c4427 (diff)
downloadFreeBSD-src-fbc3fb8fca4a0344d23fe234e0ffafc009d12547.zip
FreeBSD-src-fbc3fb8fca4a0344d23fe234e0ffafc009d12547.tar.gz
Exit cleanly if malloc() fails to allocate a buffer for a copy of the
current MBR. PR: 205322 Submitted by: Alexander Kuleshov <kuleshovmail@gmail.com> MFC after: 1 week
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/boot0cfg/boot0cfg.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/usr.sbin/boot0cfg/boot0cfg.c b/usr.sbin/boot0cfg/boot0cfg.c
index 2602e50..20b615a 100644
--- a/usr.sbin/boot0cfg/boot0cfg.c
+++ b/usr.sbin/boot0cfg/boot0cfg.c
@@ -337,6 +337,8 @@ read_mbr(const char *disk, u_int8_t **mbr, int check_version)
return (mbr_size);
}
*mbr = malloc(sizeof(buf));
+ if (mbr == NULL)
+ errx(1, "%s: unable to allocate MBR buffer", disk);
memcpy(*mbr, buf, sizeof(buf));
close(fd);
OpenPOWER on IntegriCloud