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:
jhb 2015-12-17 20:42:05 +00:00
parent 4ef184b756
commit fbc3fb8fca

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