Date: Thu, 31 Aug 2017 15:53:48 +0000 (UTC) From: Warner Losh <imp@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r323057 - head/lib/libefivar Message-ID: <201708311553.v7VFrmuN096293@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: imp Date: Thu Aug 31 15:53:47 2017 New Revision: 323057 URL: https://svnweb.freebsd.org/changeset/base/323057 Log: 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 Modified: head/lib/libefivar/efivar-dp-parse.c Modified: head/lib/libefivar/efivar-dp-parse.c ============================================================================== --- head/lib/libefivar/efivar-dp-parse.c Thu Aug 31 15:53:27 2017 (r323056) +++ head/lib/libefivar/efivar-dp-parse.c Thu Aug 31 15:53:47 2017 (r323057) @@ -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_TA {"Media", DevPathFromTextMedia }, {"Fv", DevPathFromTextFv }, {"FvFile", DevPathFromTextFvFile }, + {"File", DevPathFromTextFilePath }, {"Offset", DevPathFromTextRelativeOffsetRange }, {"RamDisk", DevPathFromTextRamDisk }, {"VirtualDisk", DevPathFromTextVirtualDisk },
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201708311553.v7VFrmuN096293>