When user specifies the bootcode with size smaller than VTOC_BOOTCODE,
gpart_write_partcode_vtoc8 does access out of range of allocated memory. Check size of bootcode before writing it. Pointed out by: ru MFC after: 1 week
This commit is contained in:
parent
f5857e2d3d
commit
8fb2868c61
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=223364
@ -1208,8 +1208,11 @@ gpart_bootcode(struct gctl_req *req, unsigned int fl)
|
|||||||
if (idx == 0)
|
if (idx == 0)
|
||||||
errx(EXIT_FAILURE, "missing -i option");
|
errx(EXIT_FAILURE, "missing -i option");
|
||||||
gpart_write_partcode(gp, idx, partcode, partsize);
|
gpart_write_partcode(gp, idx, partcode, partsize);
|
||||||
} else
|
} else {
|
||||||
|
if (partsize != VTOC_BOOTSIZE)
|
||||||
|
errx(EXIT_FAILURE, "invalid bootcode");
|
||||||
gpart_write_partcode_vtoc8(gp, idx, partcode);
|
gpart_write_partcode_vtoc8(gp, idx, partcode);
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
if (bootcode == NULL)
|
if (bootcode == NULL)
|
||||||
errx(EXIT_FAILURE, "no -b nor -p");
|
errx(EXIT_FAILURE, "no -b nor -p");
|
||||||
|
Loading…
Reference in New Issue
Block a user