[PATCH] BaseTools: Increase the DevicePath length for support more PCD value.


Currently the PCD Value only support 13 Guid,When use more 13 pcd will caus=
e the build tool fail,
Need calculate the required memory,then allocate it.

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3718

Cc: Bob Feng <bob.c.feng@...>
Cc: Liming Gao <gaoliming@...>
Cc: Yuwei Chen <yuwei.chen@...>

Signed-off-by: Xiaolu Jiang <xiaolu.jiang@...>
BaseTools/Source/C/DevicePath/DevicePath.c | 36 +++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/DevicePath/DevicePath.c b/BaseTools/Source/=
index c4d224ed61..8a0f5f4e2a 100644
--- a/BaseTools/Source/C/DevicePath/DevicePath.c
+++ b/BaseTools/Source/C/DevicePath/DevicePath.c
@@ -144,6 +144,40 @@ Returns:
*UniString =3D '\0';=0D
+ Returns the length of a Null-terminated ASCII string.=0D
+ This function returns the number of ASCII characters in the Null-termina=
+ ASCII string specified by String.=0D
+ If Length > 0 and Destination is NULL, then ASSERT().=0D
+ If Length > 0 and Source is NULL, then ASSERT().=0D
+ If PcdMaximumAsciiStringLength is not zero and String contains more than=
+ PcdMaximumAsciiStringLength ASCII characters, not including the Null-ter=
+ then ASSERT().=0D
+ @param String A pointer to a Null-terminated ASCII string.=0D
+ @return The length of String.=0D
+AsciiStrLen (=0D
+ IN CONST CHAR8 *String=0D
+ )=0D
+ UINTN Length;=0D
+ ASSERT (String !=3D NULL);=0D
+ for (Length =3D 0; *String !=3D '\0'; String++, Length++) {=0D
+ }=0D
+ return Length;=0D
int main(int argc, CHAR8 *argv[])=0D
CHAR8 * Str;=0D
@@ -170,7 +204,7 @@ int main(int argc, CHAR8 *argv[])
fprintf(stderr, "Invalid option value, Device Path can't be NULL");=0D
- Str16 =3D (CHAR16 *)malloc(1024);=0D
+ Str16 =3D (CHAR16 *)malloc((AsciiStrLen (Str) + 1) * sizeof (CHAR16));=0D
if (Str16 =3D=3D NULL) {=0D
fprintf(stderr, "Resource, memory cannot be allocated");=0D

Join devel@edk2.groups.io to automatically receive all group messages.