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:
parent
544f167747
commit
b128c3c395
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=292410
@ -337,6 +337,8 @@ read_mbr(const char *disk, u_int8_t **mbr, int check_version)
|
|||||||
return (mbr_size);
|
return (mbr_size);
|
||||||
}
|
}
|
||||||
*mbr = malloc(sizeof(buf));
|
*mbr = malloc(sizeof(buf));
|
||||||
|
if (mbr == NULL)
|
||||||
|
errx(1, "%s: unable to allocate MBR buffer", disk);
|
||||||
memcpy(*mbr, buf, sizeof(buf));
|
memcpy(*mbr, buf, sizeof(buf));
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user