Fix parsing File() nodes in device paths.
o Add File to the mUefiDevicePathLibDevPathFromTextTable table so we don't include 'File()' in the supposed path name. This happens because of a possible misfeature in the EDK2 code where any path that's not recognized is treated as a File() node. o Convert utf8 input into ucs2 output rather than just copying the utf8 and hoping for the best (no good comes from that). o Remove bogus comment about needing to add 1. The dummy array already is length 1, so that's included in sizeof the struct, so there's no need to add it. Sponsored by: Netflix
This commit is contained in:
parent
0d802f5a7a
commit
ae3adc0645
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=323057
@ -38,6 +38,8 @@ __FBSDID("$FreeBSD$");
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#include "efichar.h"
|
||||
|
||||
#include "efi-osdep.h"
|
||||
#include "efivar-dp.h"
|
||||
|
||||
@ -3031,21 +3033,15 @@ DevPathFromTextFilePath (
|
||||
|
||||
StrCpyS (File->PathName, StrLen (TextDeviceNode) + 1, TextDeviceNode);
|
||||
#else
|
||||
size_t len = (sizeof (FILEPATH_DEVICE_PATH) + StrLen (TextDeviceNode) * 2);
|
||||
efi_char * v;
|
||||
File = (FILEPATH_DEVICE_PATH *) CreateDeviceNode (
|
||||
MEDIA_DEVICE_PATH,
|
||||
MEDIA_FILEPATH_DP,
|
||||
(UINT16) (sizeof (FILEPATH_DEVICE_PATH) + StrLen (TextDeviceNode) + 1)
|
||||
(UINT16)len
|
||||
);
|
||||
|
||||
/*
|
||||
* Note: We'd have to change the Tianocore header files to fix this
|
||||
* to not need a cast. Instead we just cast it here. The Interface
|
||||
* to the user may have issues since this won't be a UCS-2
|
||||
* string. Also note that in the original code, a NUL wasn't
|
||||
* allocated for the end of the string, but we copy that below. This
|
||||
* has been corrected.
|
||||
*/
|
||||
StrCpyS ((char *)File->PathName, StrLen (TextDeviceNode) + 1, TextDeviceNode);
|
||||
v = File->PathName;
|
||||
utf8_to_ucs2(TextDeviceNode, &v, &len);
|
||||
#endif
|
||||
|
||||
return (EFI_DEVICE_PATH_PROTOCOL *) File;
|
||||
@ -3560,6 +3556,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED DEVICE_PATH_FROM_TEXT_TABLE mUefiDevicePathLibDevP
|
||||
{"Media", DevPathFromTextMedia },
|
||||
{"Fv", DevPathFromTextFv },
|
||||
{"FvFile", DevPathFromTextFvFile },
|
||||
{"File", DevPathFromTextFilePath },
|
||||
{"Offset", DevPathFromTextRelativeOffsetRange },
|
||||
{"RamDisk", DevPathFromTextRamDisk },
|
||||
{"VirtualDisk", DevPathFromTextVirtualDisk },
|
||||
|
Loading…
Reference in New Issue
Block a user