From fbc3fb8fca4a0344d23fe234e0ffafc009d12547 Mon Sep 17 00:00:00 2001 From: jhb Date: Thu, 17 Dec 2015 20:42:05 +0000 Subject: Exit cleanly if malloc() fails to allocate a buffer for a copy of the current MBR. PR: 205322 Submitted by: Alexander Kuleshov MFC after: 1 week --- usr.sbin/boot0cfg/boot0cfg.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'usr.sbin/boot0cfg') 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); -- cgit v1.1