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
This commit is contained in:
John Baldwin 2015-12-17 20:42:05 +00:00
parent 544f167747
commit b128c3c395

View File

@ -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);