Add sanity testing against maximum sane lengths for device paths for

loader and kernel.

CID: 1383608
Sponsored by: Netflix
This commit is contained in:
Warner Losh 2017-12-12 19:26:24 +00:00
parent a6b6f888b5
commit af934ea3ba
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=326804

View file

@ -650,8 +650,14 @@ make_boot_var(const char *label, const char *loader, const char *kernel, const c
kerneldp = NULL;
}
llen = efidp_size(loaderdp);
if (llen > MAX_DP_LEN)
errx(1, "Loader path too long.");
klen = efidp_size(kerneldp);
if (klen > MAX_DP_LEN)
errx(1, "Kernel path too long.");
dp = malloc(llen + klen);
if (dp == NULL)
errx(1, "Can't allocate memory for new device paths");
memcpy(dp, loaderdp, llen);
if (kerneldp != NULL)
memcpy((char *)dp + llen, kerneldp, klen);