Ensure that the device path is sane before trying to decode and print

it.

Sponsored by: Netflix, Inc
This commit is contained in:
Warner Losh 2018-10-26 22:49:36 +00:00
parent 46fabdaffc
commit 366a7b3d0c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=339799

View file

@ -2413,13 +2413,20 @@ UefiDevicePathLibConvertDevicePathToText (
}
}
ssize_t
efidp_format_device_path(char *buf, size_t len, const_efidp dp, ssize_t max)
{
char *str;
ssize_t retval;
/*
* Basic sanity check on the device path.
*/
if (!IsDevicePathValid((CONST EFI_DEVICE_PATH_PROTOCOL *) dp, max)) {
*buf = '\0';
return 0;
}
str = UefiDevicePathLibConvertDevicePathToText (
__DECONST(EFI_DEVICE_PATH_PROTOCOL *, dp), FALSE, TRUE);
if (str == NULL)