summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2016-01-19 19:04:56 +0000
committerjhb <jhb@FreeBSD.org>2016-01-19 19:04:56 +0000
commit8aa68d78585ef888d01bea9d1e045eaea835e209 (patch)
tree0e3ab2980b5bbc639a543e6e1de220c2d8aaaa0a /usr.sbin
parent0458c393d2b4a489b4776083282db929d14e971f (diff)
downloadFreeBSD-src-8aa68d78585ef888d01bea9d1e045eaea835e209.zip
FreeBSD-src-8aa68d78585ef888d01bea9d1e045eaea835e209.tar.gz
MFC 292410,292443,293977:
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>
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/boot0cfg/boot0cfg.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/usr.sbin/boot0cfg/boot0cfg.c b/usr.sbin/boot0cfg/boot0cfg.c
index 2602e50..c2cb91d 100644
--- a/usr.sbin/boot0cfg/boot0cfg.c
+++ b/usr.sbin/boot0cfg/boot0cfg.c
@@ -336,7 +336,8 @@ read_mbr(const char *disk, u_int8_t **mbr, int check_version)
close(fd);
return (mbr_size);
}
- *mbr = malloc(sizeof(buf));
+ if ((*mbr = malloc(sizeof(buf))) == NULL)
+ errx(1, "%s: unable to allocate MBR buffer", disk);
memcpy(*mbr, buf, sizeof(buf));
close(fd);
OpenPOWER on IntegriCloud