Project

General

Profile

Submit #2862 ยป 0001-boot0cfg-check-result-of-malloc-in-read_mbr.patch

Anonymous, 12/08/2015 10:43 AM

View differences:

usr.sbin/boot0cfg/boot0cfg.c
err(1, "%s", disk);
if (n != mbr_size)
errx(1, "%s: short read", disk);
close(fd);
return (mbr_size);
}
*mbr = malloc(sizeof(buf));
memcpy(*mbr, buf, sizeof(buf));
if ((*mbr = malloc(sizeof(buf))) == NULL)
errx(1, "%s: unable to allocate mbr buffer", disk);
memcpy(*mbr, buf, sizeof(buf));
close(fd);
return sizeof(buf);
}
    (1-1/1)