diff options
author | jhb <jhb@FreeBSD.org> | 2016-01-19 19:04:56 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2016-01-19 19:04:56 +0000 |
commit | 8aa68d78585ef888d01bea9d1e045eaea835e209 (patch) | |
tree | 0e3ab2980b5bbc639a543e6e1de220c2d8aaaa0a /usr.sbin | |
parent | 0458c393d2b4a489b4776083282db929d14e971f (diff) | |
download | FreeBSD-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.c | 3 |
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); |