X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FLibrary%2FUefiBootManagerLib%2FBmBoot.c;h=028edc35d53963f9c309b7bd0bdfd291f7d09888;hb=b6344b37c98a78c2a9f3b8522eb2ccbda22bc573;hp=2d3d57b3e9166bfc503445759393c970d7f09432;hpb=93fd37dc0be4ecc4ba572ebac07ec3f0e3d86cfa;p=mirror_edk2.git diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c index 2d3d57b3e9..028edc35d5 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c @@ -552,6 +552,7 @@ BmGetUsbDescription ( CHAR16 *SerialNumber; CHAR16 *Description; EFI_USB_DEVICE_DESCRIPTOR DevDesc; + UINTN DescMaxSize; Status = gBS->HandleProtocol ( Handle, @@ -606,15 +607,16 @@ BmGetUsbDescription ( return NULL; } - Description = AllocateZeroPool (StrSize (Manufacturer) + StrSize (Product) + StrSize (SerialNumber)); + DescMaxSize = StrSize (Manufacturer) + StrSize (Product) + StrSize (SerialNumber); + Description = AllocateZeroPool (DescMaxSize); ASSERT (Description != NULL); - StrCat (Description, Manufacturer); - StrCat (Description, L" "); + StrCatS (Description, DescMaxSize/sizeof(CHAR16), Manufacturer); + StrCatS (Description, DescMaxSize/sizeof(CHAR16), L" "); - StrCat (Description, Product); - StrCat (Description, L" "); + StrCatS (Description, DescMaxSize/sizeof(CHAR16), Product); + StrCatS (Description, DescMaxSize/sizeof(CHAR16), L" "); - StrCat (Description, SerialNumber); + StrCatS (Description, DescMaxSize/sizeof(CHAR16), SerialNumber); if (Manufacturer != &NullChar) { FreePool (Manufacturer); @@ -774,8 +776,14 @@ BmGetBootDescription ( // Temp = AllocatePool (StrSize (DefaultDescription) + sizeof (mBmUefiPrefix)); ASSERT (Temp != NULL); - StrCpy (Temp, mBmUefiPrefix); - StrCat (Temp, DefaultDescription); + StrCpyS ( Temp, + (StrSize (DefaultDescription) + sizeof (mBmUefiPrefix))/sizeof(CHAR16), + mBmUefiPrefix + ); + StrCatS ( Temp, + (StrSize (DefaultDescription) + sizeof (mBmUefiPrefix))/sizeof(CHAR16), + DefaultDescription + ); FreePool (DefaultDescription); DefaultDescription = Temp; break;