aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/efibootmgr/efibootmgr.c
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2017-12-12 19:26:24 +0000
committerWarner Losh <imp@FreeBSD.org>2017-12-12 19:26:24 +0000
commitaf934ea3ba5df1d8f18c141ba1685e70e7356bac (patch)
tree3afe8095d3f3eda43edd68b551a2f366bb0b43a7 /usr.sbin/efibootmgr/efibootmgr.c
parenta6b6f888b524de8d4917ab502db43734d2c5b5ed (diff)
downloadsrc-af934ea3ba5df1d8f18c141ba1685e70e7356bac.tar.gz
src-af934ea3ba5df1d8f18c141ba1685e70e7356bac.zip
Add sanity testing against maximum sane lengths for device paths for
loader and kernel. CID: 1383608 Sponsored by: Netflix
Notes
Notes: svn path=/head/; revision=326804
Diffstat (limited to 'usr.sbin/efibootmgr/efibootmgr.c')
-rw-r--r--usr.sbin/efibootmgr/efibootmgr.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/usr.sbin/efibootmgr/efibootmgr.c b/usr.sbin/efibootmgr/efibootmgr.c
index 95bb18a6f431..ffbbb61776a8 100644
--- a/usr.sbin/efibootmgr/efibootmgr.c
+++ b/usr.sbin/efibootmgr/efibootmgr.c
@@ -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);