Browse Source

QuarkPlatformPkg: Use safe string functions

Update QuarkPlatformPkg modules to use safe string
functions from BaseLib.

Cc: Kelly Steele <kelly.steele@intel.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Kelly Steele <kelly.steele@intel.com>
Michael D Kinney 3 years ago
parent
commit
6a3088d12e

+ 2 - 2
Platform/Intel/QuarkPlatformPkg/Acpi/Dxe/AcpiPlatform/AcpiPciUpdate.c

@@ -903,9 +903,9 @@ SdtCheckReturnPackage (
 
       if (DataType == EFI_ACPI_DATA_TYPE_NAME_STRING) {
         ZeroMem (NameStr, 128);
-        AsciiStrCpy (NameStr, "\\_SB.");
+        AsciiStrCpyS (NameStr, 128, "\\_SB.");
         DataSize = SdtGetNameStringSize (Data);
-        AsciiStrnCat (NameStr, (CHAR8 *)Data, DataSize);
+        AsciiStrnCatS (NameStr, 128, (CHAR8 *)Data, DataSize);
 
         NamePkgHandle = NULL;
         Status = AcpiSdt->FindPath (mDsdtHandle, NameStr, &NamePkgHandle);

+ 8 - 8
Platform/Intel/QuarkPlatformPkg/Platform/Dxe/MemorySubClass/MemorySubClass.c

@@ -205,7 +205,7 @@ MemorySubClassEntryPoint (
   ArrayLink.MemoryType = EfiMemoryTypeDdr2;
 
 
-  StrCpy (StringBuffer, L"NO DIMM,MEMROY DOWN");
+  StrCpyS (StringBuffer, StringBufferSize / sizeof (CHAR16), L"NO DIMM,MEMROY DOWN");
   ArrayLink.MemoryManufacturer = HiiSetString (
                                    HiiHandle,
                                    0,
@@ -317,7 +317,7 @@ MemorySubClassEntryPoint (
     *(UINT16*)&Type6Record->CurrentMemoryType |= 1<<3;
   }
   OptionalStrStart = (CHAR8 *)(Type6Record + 1);
-  UnicodeStrToAsciiStr(DevLocStr, OptionalStrStart);
+  UnicodeStrToAsciiStrS (DevLocStr, OptionalStrStart, DevLocStrLen + 1);
   MemModuleInfoSmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
   Status = Smbios->Add (Smbios, NULL, &MemModuleInfoSmbiosHandle, (EFI_SMBIOS_TABLE_HEADER*) Type6Record);
   FreePool(Type6Record);
@@ -379,12 +379,12 @@ MemorySubClassEntryPoint (
   Type17Record->Attributes = (UINT8)(Dimm + 1);
 
   OptionalStrStart = (CHAR8 *)(Type17Record + 1);
-  UnicodeStrToAsciiStr(DevLocStr, OptionalStrStart);
-  UnicodeStrToAsciiStr(BankLocStr, OptionalStrStart + DevLocStrLen + 1);
-  UnicodeStrToAsciiStr(ManuStr, OptionalStrStart + DevLocStrLen + 1 + BankLocStrLen + 1);
-  UnicodeStrToAsciiStr(SerialNumStr, OptionalStrStart + DevLocStrLen + 1 + BankLocStrLen + 1 + ManuStrLen + 1);
-  UnicodeStrToAsciiStr(AssertTagStr, OptionalStrStart + DevLocStrLen + 1 + BankLocStrLen + 1 + ManuStrLen + 1 + SerialNumStrLen + 1);
-  UnicodeStrToAsciiStr(PartNumStr, OptionalStrStart + DevLocStrLen + 1 + BankLocStrLen + 1 + ManuStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1);
+  UnicodeStrToAsciiStrS (DevLocStr, OptionalStrStart, DevLocStrLen + 1);
+  UnicodeStrToAsciiStrS (BankLocStr, OptionalStrStart + DevLocStrLen + 1, BankLocStrLen + 1);
+  UnicodeStrToAsciiStrS (ManuStr, OptionalStrStart + DevLocStrLen + 1 + BankLocStrLen + 1, ManuStrLen + 1);
+  UnicodeStrToAsciiStrS (SerialNumStr, OptionalStrStart + DevLocStrLen + 1 + BankLocStrLen + 1 + ManuStrLen + 1, SerialNumStrLen + 1);
+  UnicodeStrToAsciiStrS (AssertTagStr, OptionalStrStart + DevLocStrLen + 1 + BankLocStrLen + 1 + ManuStrLen + 1 + SerialNumStrLen + 1, AssertTagStrLen + 1);
+  UnicodeStrToAsciiStrS (PartNumStr, OptionalStrStart + DevLocStrLen + 1 + BankLocStrLen + 1 + ManuStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1, PartNumStrLen + 1);
   MemDevSmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
   Status = Smbios->Add (Smbios, NULL, &MemDevSmbiosHandle, (EFI_SMBIOS_TABLE_HEADER*) Type17Record);
   FreePool(Type17Record);

+ 8 - 8
Platform/Intel/QuarkPlatformPkg/Platform/Dxe/SmbiosMiscDxe/MiscBaseBoardManufacturerFunction.c

@@ -64,13 +64,13 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
     return EFI_UNSUPPORTED;
   }
 
-  StrCpy (TypeString, L"");
+  StrCpyS (TypeString, ARRAY_SIZE (TypeString), L"");
   TypeStringSize = PcdGetSize (PcdPlatformTypeName);
   if (TypeStringSize > 0 && TypeStringSize <= sizeof (TypeString)) {
     CopyMem (TypeString, PcdGetPtr (PcdPlatformTypeName), TypeStringSize);
   }
   if (StrLen (TypeString) == 0) {
-    StrCpy (TypeString, L"Unknown");
+    StrCpyS (TypeString, ARRAY_SIZE (TypeString), L"Unknown");
   }
   TokenToUpdate = STRING_TOKEN (STR_MISC_BASE_BOARD_PRODUCT_NAME);
   HiiSetString (mHiiHandle, TokenToUpdate, TypeString, NULL);
@@ -158,12 +158,12 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer)
   // Since we fill NumberOfContainedObjectHandles = 0 for simple, just after this filed to fill string
   //
   //OptionalStrStart -= 2;
-  UnicodeStrToAsciiStr(Manufacturer, OptionalStrStart);
-  UnicodeStrToAsciiStr(Product, OptionalStrStart + ManuStrLen + 1);
-  UnicodeStrToAsciiStr(Version, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1);
-  UnicodeStrToAsciiStr(SerialNumber, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1);
-  UnicodeStrToAsciiStr(AssertTag, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);
-  UnicodeStrToAsciiStr(Chassis, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1);
+  UnicodeStrToAsciiStrS (Manufacturer, OptionalStrStart, ManuStrLen + 1);
+  UnicodeStrToAsciiStrS (Product, OptionalStrStart + ManuStrLen + 1, ProductStrLen + 1);
+  UnicodeStrToAsciiStrS (Version, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1, VerStrLen + 1);
+  UnicodeStrToAsciiStrS (SerialNumber, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1, SerialNumStrLen + 1);
+  UnicodeStrToAsciiStrS (AssertTag, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1, AssertTagStrLen + 1);
+  UnicodeStrToAsciiStrS (Chassis, OptionalStrStart + ManuStrLen + 1 + ProductStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + AssertTagStrLen + 1, ChassisStrLen + 1);
 
   //
   // Now we have got the full smbios record, call smbios protocol to add this record.

+ 5 - 5
Platform/Intel/QuarkPlatformPkg/Platform/Dxe/SmbiosMiscDxe/MiscBiosVendorFunction.c

@@ -128,7 +128,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBiosVendor)
   //
   // Update strings from PCD
   //
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr (PcdSMBIOSBiosVendor), Vendor);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr (PcdSMBIOSBiosVendor), Vendor, ARRAY_SIZE (Vendor));
   if (StrLen (Vendor) > 0) {
     TokenToUpdate = STRING_TOKEN (STR_MISC_BIOS_VENDOR);
     HiiSetString (mHiiHandle, TokenToUpdate, Vendor, NULL);
@@ -152,7 +152,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBiosVendor)
     return EFI_UNSUPPORTED;
   }
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr (PcdSMBIOSBiosReleaseDate), ReleaseDate);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr (PcdSMBIOSBiosReleaseDate), ReleaseDate, ARRAY_SIZE (ReleaseDate));
   if (StrLen (ReleaseDate) > 0) {
     TokenToUpdate = STRING_TOKEN (STR_MISC_BIOS_RELEASE_DATE);
     HiiSetString (mHiiHandle, TokenToUpdate, ReleaseDate, NULL);
@@ -203,9 +203,9 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBiosVendor)
   SmbiosRecord->EmbeddedControllerFirmwareMinorRelease = ForType0InputData->BiosEmbeddedFirmwareMinorRelease;
 
   OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
-  UnicodeStrToAsciiStr(VendorPtr, OptionalStrStart);
-  UnicodeStrToAsciiStr(VersionPtr, OptionalStrStart + VendorStrLen + 1);
-  UnicodeStrToAsciiStr(ReleaseDatePtr, OptionalStrStart + VendorStrLen + 1 + VerStrLen + 1);
+  UnicodeStrToAsciiStrS (VendorPtr, OptionalStrStart, VendorStrLen + 1);
+  UnicodeStrToAsciiStrS (VersionPtr, OptionalStrStart + VendorStrLen + 1, VendorStrLen + 1);
+  UnicodeStrToAsciiStrS (ReleaseDatePtr, OptionalStrStart + VendorStrLen + 1 + VerStrLen + 1, DateStrLen + 1);
   //
   // Now we have got the full smbios record, call smbios protocol to add this record.
   //

+ 8 - 8
Platform/Intel/QuarkPlatformPkg/Platform/Dxe/SmbiosMiscDxe/MiscChassisManufacturerFunction.c

@@ -59,7 +59,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscChassisManufacturer)
   //
   // Update strings from PCD
   //
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSChassisManufacturer), Manufacturer);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSChassisManufacturer), Manufacturer, ARRAY_SIZE (Manufacturer));
   if (StrLen (Manufacturer) > 0) {
     TokenToUpdate = STRING_TOKEN (STR_MISC_CHASSIS_MANUFACTURER);
     HiiSetString (mHiiHandle, TokenToUpdate, Manufacturer, NULL);
@@ -71,7 +71,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscChassisManufacturer)
     return EFI_UNSUPPORTED;
   }
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSChassisVersion), Version);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSChassisVersion), Version, ARRAY_SIZE (Version));
   if (StrLen (Version) > 0) {
     TokenToUpdate = STRING_TOKEN (STR_MISC_CHASSIS_VERSION);
     HiiSetString (mHiiHandle, TokenToUpdate, Version, NULL);
@@ -83,7 +83,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscChassisManufacturer)
     return EFI_UNSUPPORTED;
   }
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSChassisSerialNumber), SerialNumber);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSChassisSerialNumber), SerialNumber, ARRAY_SIZE (SerialNumber));
   if (StrLen (SerialNumber) > 0) {
     TokenToUpdate = STRING_TOKEN (STR_MISC_CHASSIS_SERIAL_NUMBER);
     HiiSetString (mHiiHandle, TokenToUpdate, SerialNumber, NULL);
@@ -95,7 +95,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscChassisManufacturer)
     return EFI_UNSUPPORTED;
   }
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSChassisAssetTag), AssertTag);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSChassisAssetTag), AssertTag, ARRAY_SIZE (AssertTag));
   if (StrLen (AssertTag) > 0) {
     TokenToUpdate = STRING_TOKEN (STR_MISC_CHASSIS_ASSET_TAG);
     HiiSetString (mHiiHandle, TokenToUpdate, AssertTag, NULL);
@@ -147,10 +147,10 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscChassisManufacturer)
   SmbiosRecord->ContainedElementRecordLength = PcdGet8 (PcdSMBIOSChassisElementRecordLength);
 
   OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
-  UnicodeStrToAsciiStr(ManufacturerPtr, OptionalStrStart);
-  UnicodeStrToAsciiStr(VersionPtr, OptionalStrStart + ManuStrLen + 1);
-  UnicodeStrToAsciiStr(SerialNumberPtr, OptionalStrStart + ManuStrLen + 1 + VerStrLen + 1);
-  UnicodeStrToAsciiStr(AssertTagPtr, OptionalStrStart + ManuStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1);
+  UnicodeStrToAsciiStrS (ManufacturerPtr, OptionalStrStart, ManuStrLen + 1);
+  UnicodeStrToAsciiStrS (VersionPtr, OptionalStrStart + ManuStrLen + 1, VerStrLen + 1);
+  UnicodeStrToAsciiStrS (SerialNumberPtr, OptionalStrStart + ManuStrLen + 1 + VerStrLen + 1, SerialNumStrLen + 1);
+  UnicodeStrToAsciiStrS (AssertTagPtr, OptionalStrStart + ManuStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1, AssertTagStrLen + 1);
 
   //
   // Now we have got the full smbios record, call smbios protocol to add this record.

+ 13 - 9
Platform/Intel/QuarkPlatformPkg/Platform/Dxe/SmbiosMiscDxe/MiscNumberOfInstallableLanguagesFunction.c

@@ -32,13 +32,14 @@ CurrentLanguageMatch (
   OUT CHAR8                            *CurrentLang
   )
 {
-  CHAR8     *DefaultLang;
-  CHAR8     *BestLanguage;
-  CHAR8     *Languages;
-  CHAR8     *MatchLang;
-  CHAR8     *EndMatchLang;
-  UINTN     CompareLength;
-  BOOLEAN   LangMatch;
+  EFI_STATUS  Status;
+  CHAR8       *DefaultLang;
+  CHAR8       *BestLanguage;
+  CHAR8       *Languages;
+  CHAR8       *MatchLang;
+  CHAR8       *EndMatchLang;
+  UINTN       CompareLength;
+  BOOLEAN     LangMatch;
 
   Languages = HiiGetSupportedLanguages (HiiHandle);
   if (Languages == NULL) {
@@ -46,7 +47,10 @@ CurrentLanguageMatch (
   }
 
   LangMatch = FALSE;
-  CurrentLang  = GetEfiGlobalVariable (L"PlatformLang");
+  Status = GetEfiGlobalVariable2 (L"PlatformLang", &CurrentLang, NULL);
+  if (EFI_ERROR (Status)) {
+    return FALSE;
+  }
   DefaultLang  = (CHAR8 *) PcdGetPtr (PcdUefiVariableDefaultPlatformLang);
   BestLanguage = GetBestLanguage (
                    Languages,
@@ -224,7 +228,7 @@ MISC_SMBIOS_TABLE_FUNCTION(NumberOfInstallableLanguages)
   SmbiosRecord->Flags = (UINT8)ForType13InputData->LanguageFlags.AbbreviatedLanguageFormat;
   SmbiosRecord->CurrentLanguages = 1;
   OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
-  AsciiStrCpy(OptionalStrStart, CurrentLang);
+  AsciiStrCpyS (OptionalStrStart, LangStrLen + 1, CurrentLang);
   //
   // Now we have got the full smbios record, call smbios protocol to add this record.
   //

+ 1 - 1
Platform/Intel/QuarkPlatformPkg/Platform/Dxe/SmbiosMiscDxe/MiscOemStringFunction.c

@@ -61,7 +61,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscOemString)
   SmbiosRecord->Hdr.Handle = 0;
   SmbiosRecord->StringCount = 1;
   OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
-  UnicodeStrToAsciiStr(OemStr, OptionalStrStart);
+  UnicodeStrToAsciiStrS (OemStr, OptionalStrStart, OemStrLen + 1);
 
   //
   // Now we have got the full smbios record, call smbios protocol to add this record.

+ 1 - 1
Platform/Intel/QuarkPlatformPkg/Platform/Dxe/SmbiosMiscDxe/MiscOnboardDeviceFunction.c

@@ -88,7 +88,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscOnboardDevice)
   SmbiosRecord->Device[0].DeviceType = StatusAndType;
   SmbiosRecord->Device[0].DescriptionString = 1;
   OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
-  UnicodeStrToAsciiStr(DeviceDescription, OptionalStrStart);
+  UnicodeStrToAsciiStrS (DeviceDescription, OptionalStrStart, DescriptionStrLen + 1);
 
   //
   // Now we have got the full smbios record, call smbios protocol to add this record.

+ 30 - 30
Platform/Intel/QuarkPlatformPkg/Platform/Dxe/SmbiosMiscDxe/MiscPortInternalConnectorDesignatorFunction.c

@@ -81,86 +81,86 @@ GetMiscPortConfigFromPcd ()
   // Type 8
   //
   SMBIOSPortConnector.SMBIOSConnectorNumber = PcdGet8 (PcdSMBIOSConnectorNumber);
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort1InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[0].PortInternalConnectorDesignator);
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort1ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[0].PortExternalConnectorDesignator);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort1InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[0].PortInternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[0].PortInternalConnectorDesignator));
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort1ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[0].PortExternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[0].PortExternalConnectorDesignator));
   SMBIOSPortConnector.SMBIOSPortConnector[0].PortInternalConnectorType = PcdGet8 (PcdSMBIOSPort1InternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[0].PortExternalConnectorType = PcdGet8 (PcdSMBIOSPort1ExternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[0].PortType = PcdGet8 (PcdSMBIOSPort1Type);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort2InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[1].PortInternalConnectorDesignator);
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort2ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[1].PortExternalConnectorDesignator);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort2InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[1].PortInternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[1].PortInternalConnectorDesignator));
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort2ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[1].PortExternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[1].PortExternalConnectorDesignator));
   SMBIOSPortConnector.SMBIOSPortConnector[1].PortInternalConnectorType = PcdGet8 (PcdSMBIOSPort2InternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[1].PortExternalConnectorType = PcdGet8 (PcdSMBIOSPort2ExternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[1].PortType = PcdGet8 (PcdSMBIOSPort2Type);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort3InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[2].PortInternalConnectorDesignator);
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort3ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[2].PortExternalConnectorDesignator);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort3InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[2].PortInternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[2].PortInternalConnectorDesignator));
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort3ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[2].PortExternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[2].PortExternalConnectorDesignator));
   SMBIOSPortConnector.SMBIOSPortConnector[2].PortInternalConnectorType = PcdGet8 (PcdSMBIOSPort3InternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[2].PortExternalConnectorType = PcdGet8 (PcdSMBIOSPort3ExternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[2].PortType = PcdGet8 (PcdSMBIOSPort3Type);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort4InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[3].PortInternalConnectorDesignator);
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort4ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[3].PortExternalConnectorDesignator);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort4InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[3].PortInternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[3].PortInternalConnectorDesignator));
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort4ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[3].PortExternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[3].PortExternalConnectorDesignator));
   SMBIOSPortConnector.SMBIOSPortConnector[3].PortInternalConnectorType = PcdGet8 (PcdSMBIOSPort4InternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[3].PortExternalConnectorType = PcdGet8 (PcdSMBIOSPort4ExternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[3].PortType = PcdGet8 (PcdSMBIOSPort4Type);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort5InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[4].PortInternalConnectorDesignator);
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort5ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[4].PortExternalConnectorDesignator);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort5InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[4].PortInternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[4].PortInternalConnectorDesignator));
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort5ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[4].PortExternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[4].PortExternalConnectorDesignator));
   SMBIOSPortConnector.SMBIOSPortConnector[4].PortInternalConnectorType = PcdGet8 (PcdSMBIOSPort5InternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[4].PortExternalConnectorType = PcdGet8 (PcdSMBIOSPort5ExternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[4].PortType = PcdGet8 (PcdSMBIOSPort5Type);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort6InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[5].PortInternalConnectorDesignator);
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort6ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[5].PortExternalConnectorDesignator);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort6InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[5].PortInternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[5].PortInternalConnectorDesignator));
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort6ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[5].PortExternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[5].PortExternalConnectorDesignator));
   SMBIOSPortConnector.SMBIOSPortConnector[5].PortInternalConnectorType = PcdGet8 (PcdSMBIOSPort6InternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[5].PortExternalConnectorType = PcdGet8 (PcdSMBIOSPort6ExternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[5].PortType = PcdGet8 (PcdSMBIOSPort6Type);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort7InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[6].PortInternalConnectorDesignator);
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort7ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[6].PortExternalConnectorDesignator);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort7InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[6].PortInternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[6].PortInternalConnectorDesignator));
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort7ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[6].PortExternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[6].PortExternalConnectorDesignator));
   SMBIOSPortConnector.SMBIOSPortConnector[6].PortInternalConnectorType = PcdGet8 (PcdSMBIOSPort7InternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[6].PortExternalConnectorType = PcdGet8 (PcdSMBIOSPort7ExternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[6].PortType = PcdGet8 (PcdSMBIOSPort7Type);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort8InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[7].PortInternalConnectorDesignator);
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort8ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[7].PortExternalConnectorDesignator);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort8InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[7].PortInternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[7].PortInternalConnectorDesignator));
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort8ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[7].PortExternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[7].PortExternalConnectorDesignator));
   SMBIOSPortConnector.SMBIOSPortConnector[7].PortInternalConnectorType = PcdGet8 (PcdSMBIOSPort8InternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[7].PortExternalConnectorType = PcdGet8 (PcdSMBIOSPort8ExternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[7].PortType = PcdGet8 (PcdSMBIOSPort8Type);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort9InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[8].PortInternalConnectorDesignator);
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort9ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[8].PortExternalConnectorDesignator);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort9InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[8].PortInternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[8].PortInternalConnectorDesignator));
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort9ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[8].PortExternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[8].PortExternalConnectorDesignator));
   SMBIOSPortConnector.SMBIOSPortConnector[8].PortInternalConnectorType = PcdGet8 (PcdSMBIOSPort9InternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[8].PortExternalConnectorType = PcdGet8 (PcdSMBIOSPort9ExternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[8].PortType = PcdGet8 (PcdSMBIOSPort9Type);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort10InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[9].PortInternalConnectorDesignator);
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort10ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[9].PortExternalConnectorDesignator);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort10InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[9].PortInternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[9].PortInternalConnectorDesignator));
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort10ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[9].PortExternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[9].PortExternalConnectorDesignator));
   SMBIOSPortConnector.SMBIOSPortConnector[9].PortInternalConnectorType = PcdGet8 (PcdSMBIOSPort10InternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[9].PortExternalConnectorType = PcdGet8 (PcdSMBIOSPort10ExternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[9].PortType = PcdGet8 (PcdSMBIOSPort10Type);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort11InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[10].PortInternalConnectorDesignator);
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort11ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[10].PortExternalConnectorDesignator);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort11InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[10].PortInternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[10].PortInternalConnectorDesignator));
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort11ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[10].PortExternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[10].PortExternalConnectorDesignator));
   SMBIOSPortConnector.SMBIOSPortConnector[10].PortInternalConnectorType = PcdGet8 (PcdSMBIOSPort11InternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[10].PortExternalConnectorType = PcdGet8 (PcdSMBIOSPort11ExternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[10].PortType = PcdGet8 (PcdSMBIOSPort11Type);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort12InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[11].PortInternalConnectorDesignator);
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort12ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[11].PortExternalConnectorDesignator);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort12InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[11].PortInternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[11].PortInternalConnectorDesignator));
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort12ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[11].PortExternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[11].PortExternalConnectorDesignator));
   SMBIOSPortConnector.SMBIOSPortConnector[11].PortInternalConnectorType = PcdGet8 (PcdSMBIOSPort12InternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[11].PortExternalConnectorType = PcdGet8 (PcdSMBIOSPort12ExternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[11].PortType = PcdGet8 (PcdSMBIOSPort12Type);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort13InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[12].PortInternalConnectorDesignator);
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort13ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[12].PortExternalConnectorDesignator);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort13InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[12].PortInternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[12].PortInternalConnectorDesignator));
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort13ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[12].PortExternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[12].PortExternalConnectorDesignator));
   SMBIOSPortConnector.SMBIOSPortConnector[12].PortInternalConnectorType = PcdGet8 (PcdSMBIOSPort13InternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[12].PortExternalConnectorType = PcdGet8 (PcdSMBIOSPort13ExternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[12].PortType = PcdGet8 (PcdSMBIOSPort13Type);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort14InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[13].PortInternalConnectorDesignator);
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort14ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[13].PortExternalConnectorDesignator);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort14InternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[13].PortInternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[13].PortInternalConnectorDesignator));
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSPort14ExternalConnectorDesignator), SMBIOSPortConnector.SMBIOSPortConnector[13].PortExternalConnectorDesignator, ARRAY_SIZE (SMBIOSPortConnector.SMBIOSPortConnector[13].PortExternalConnectorDesignator));
   SMBIOSPortConnector.SMBIOSPortConnector[13].PortInternalConnectorType = PcdGet8 (PcdSMBIOSPort14InternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[13].PortExternalConnectorType = PcdGet8 (PcdSMBIOSPort14ExternalConnectorType);
   SMBIOSPortConnector.SMBIOSPortConnector[13].PortType = PcdGet8 (PcdSMBIOSPort14Type);
@@ -274,8 +274,8 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscPortInternalConnectorDesignator)
   SmbiosRecord->PortType = PortType;
 
   OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
-  UnicodeStrToAsciiStr(InternalRef, OptionalStrStart);
-  UnicodeStrToAsciiStr(ExternalRef, OptionalStrStart + InternalRefStrLen + 1);
+  UnicodeStrToAsciiStrS (InternalRef, OptionalStrStart, InternalRefStrLen + 1);
+  UnicodeStrToAsciiStrS (ExternalRef, OptionalStrStart + InternalRefStrLen + 1, ExternalRefStrLen + 1);
 
   //
   // Now we have got the full smbios record, call smbios protocol to add this record.

+ 12 - 12
Platform/Intel/QuarkPlatformPkg/Platform/Dxe/SmbiosMiscDxe/MiscSystemManufacturerFunction.c

@@ -65,7 +65,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscSystemManufacturer)
   //
   // Update strings from PCD
   //
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemManufacturer), Manufacturer);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemManufacturer), Manufacturer, ARRAY_SIZE (Manufacturer));
   if (StrLen (Manufacturer) > 0) {
     TokenToUpdate = STRING_TOKEN (STR_MISC_SYSTEM_MANUFACTURER);
     HiiSetString (mHiiHandle, TokenToUpdate, Manufacturer, NULL);
@@ -77,7 +77,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscSystemManufacturer)
     return EFI_UNSUPPORTED;
   }
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemProductName), ProductName);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemProductName), ProductName, ARRAY_SIZE (ProductName));
   if (StrLen (ProductName) > 0) {
     TokenToUpdate = STRING_TOKEN (STR_MISC_SYSTEM_PRODUCT_NAME);
     HiiSetString (mHiiHandle, TokenToUpdate, ProductName, NULL);
@@ -89,7 +89,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscSystemManufacturer)
     return EFI_UNSUPPORTED;
   }
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemVersion), Version);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemVersion), Version, ARRAY_SIZE (Version));
   if (StrLen (Version) > 0) {
     TokenToUpdate = STRING_TOKEN (STR_MISC_SYSTEM_VERSION);
     HiiSetString (mHiiHandle, TokenToUpdate, Version, NULL);
@@ -101,7 +101,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscSystemManufacturer)
     return EFI_UNSUPPORTED;
   }
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSerialNumber), SerialNumber);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSerialNumber), SerialNumber, ARRAY_SIZE (SerialNumber));
   if (StrLen (SerialNumber) > 0) {
     TokenToUpdate = STRING_TOKEN (STR_MISC_SYSTEM_SERIAL_NUMBER);
     HiiSetString (mHiiHandle, TokenToUpdate, SerialNumber, NULL);
@@ -113,7 +113,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscSystemManufacturer)
     return EFI_UNSUPPORTED;
   }
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSKUNumber), SKUNumber);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSKUNumber), SKUNumber, ARRAY_SIZE (SKUNumber));
   if (StrLen (SKUNumber) > 0) {
     TokenToUpdate = STRING_TOKEN (STR_MISC_SYSTEM_SKU_NUMBER);
     HiiSetString (mHiiHandle, TokenToUpdate, SKUNumber, NULL);
@@ -125,7 +125,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscSystemManufacturer)
     return EFI_UNSUPPORTED;
   }
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemFamily), Family);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemFamily), Family, ARRAY_SIZE (Family));
   if (StrLen (Family) > 0) {
     TokenToUpdate = STRING_TOKEN (STR_MISC_SYSTEM_FAMILY);
     HiiSetString (mHiiHandle, TokenToUpdate, Family, NULL);
@@ -176,12 +176,12 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscSystemManufacturer)
   SmbiosRecord->WakeUpType = (UINT8)ForType1InputData->SystemWakeupType;
 
   OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
-  UnicodeStrToAsciiStr(ManufacturerPtr, OptionalStrStart);
-  UnicodeStrToAsciiStr(ProductNamePtr, OptionalStrStart + ManuStrLen + 1);
-  UnicodeStrToAsciiStr(VersionPtr, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1);
-  UnicodeStrToAsciiStr(SerialNumberPtr, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1);
-  UnicodeStrToAsciiStr(SKUNumberPtr, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen+ 1);
-  UnicodeStrToAsciiStr(FamilyPtr, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SKUNumStrLen+ 1);
+  UnicodeStrToAsciiStrS (ManufacturerPtr, OptionalStrStart, ManuStrLen + 1);
+  UnicodeStrToAsciiStrS (ProductNamePtr, OptionalStrStart + ManuStrLen + 1, PdNameStrLen + 1);
+  UnicodeStrToAsciiStrS (VersionPtr, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1, VerStrLen + 1);
+  UnicodeStrToAsciiStrS (SerialNumberPtr, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1, SerialNumStrLen + 1);
+  UnicodeStrToAsciiStrS (SKUNumberPtr, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen+ 1, SKUNumStrLen + 1);
+  UnicodeStrToAsciiStrS (FamilyPtr, OptionalStrStart + ManuStrLen + 1 + PdNameStrLen + 1 + VerStrLen + 1 + SerialNumStrLen + 1 + SKUNumStrLen+ 1, FamilyStrLen + 1);
 
   //
   // Now we have got the full smbios record, call smbios protocol to add this record.

+ 1 - 1
Platform/Intel/QuarkPlatformPkg/Platform/Dxe/SmbiosMiscDxe/MiscSystemOptionStringFunction.c

@@ -64,7 +64,7 @@ MISC_SMBIOS_TABLE_FUNCTION(SystemOptionString)
 
   SmbiosRecord->StringCount = 1;
   OptionalStrStart = (CHAR8*) (SmbiosRecord + 1);
-  UnicodeStrToAsciiStr(OptionString, OptionalStrStart);
+  UnicodeStrToAsciiStrS (OptionString, OptionalStrStart, OptStrLen + 1);
   //
   // Now we have got the full smbios record, call smbios protocol to add this record.
   //

+ 15 - 15
Platform/Intel/QuarkPlatformPkg/Platform/Dxe/SmbiosMiscDxe/MiscSystemSlotDesignationFunction.c

@@ -69,7 +69,7 @@ GetMiscSLotConfigFromPcd ()
   // Type 9
   //
   SMBIOSlotConfig.SMBIOSSystemSlotNumber = PcdGet8 (PcdSMBIOSSystemSlotNumber);
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot1Designation), SMBIOSlotConfig.SMBIOSSystemSlot[0].SlotDesignation);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot1Designation), SMBIOSlotConfig.SMBIOSSystemSlot[0].SlotDesignation, ARRAY_SIZE (SMBIOSlotConfig.SMBIOSSystemSlot[0].SlotDesignation));
   SMBIOSlotConfig.SMBIOSSystemSlot[0].SlotType = PcdGet8(PcdSMBIOSSystemSlot1Type);
   SMBIOSlotConfig.SMBIOSSystemSlot[0].SlotDataBusWidth = PcdGet8(PcdSMBIOSSystemSlot1DataBusWidth);
   SMBIOSlotConfig.SMBIOSSystemSlot[0].SlotUsage = PcdGet8(PcdSMBIOSSystemSlot1Usage);
@@ -77,7 +77,7 @@ GetMiscSLotConfigFromPcd ()
   SMBIOSlotConfig.SMBIOSSystemSlot[0].SlotId = PcdGet16(PcdSMBIOSSystemSlot1Id);
   SMBIOSlotConfig.SMBIOSSystemSlot[0].SlotCharacteristics = PcdGet32(PcdSMBIOSSystemSlot1Characteristics);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot2Designation), SMBIOSlotConfig.SMBIOSSystemSlot[1].SlotDesignation);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot2Designation), SMBIOSlotConfig.SMBIOSSystemSlot[1].SlotDesignation, ARRAY_SIZE (SMBIOSlotConfig.SMBIOSSystemSlot[1].SlotDesignation));
   SMBIOSlotConfig.SMBIOSSystemSlot[1].SlotType = PcdGet8(PcdSMBIOSSystemSlot2Type);
   SMBIOSlotConfig.SMBIOSSystemSlot[1].SlotDataBusWidth = PcdGet8(PcdSMBIOSSystemSlot2DataBusWidth);
   SMBIOSlotConfig.SMBIOSSystemSlot[1].SlotUsage = PcdGet8(PcdSMBIOSSystemSlot2Usage);
@@ -85,7 +85,7 @@ GetMiscSLotConfigFromPcd ()
   SMBIOSlotConfig.SMBIOSSystemSlot[1].SlotId = PcdGet16(PcdSMBIOSSystemSlot2Id);
   SMBIOSlotConfig.SMBIOSSystemSlot[1].SlotCharacteristics = PcdGet32(PcdSMBIOSSystemSlot2Characteristics);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot3Designation), SMBIOSlotConfig.SMBIOSSystemSlot[2].SlotDesignation);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot3Designation), SMBIOSlotConfig.SMBIOSSystemSlot[2].SlotDesignation, ARRAY_SIZE (SMBIOSlotConfig.SMBIOSSystemSlot[2].SlotDesignation));
   SMBIOSlotConfig.SMBIOSSystemSlot[2].SlotType = PcdGet8(PcdSMBIOSSystemSlot3Type);
   SMBIOSlotConfig.SMBIOSSystemSlot[2].SlotDataBusWidth = PcdGet8(PcdSMBIOSSystemSlot3DataBusWidth);
   SMBIOSlotConfig.SMBIOSSystemSlot[2].SlotUsage = PcdGet8(PcdSMBIOSSystemSlot3Usage);
@@ -93,7 +93,7 @@ GetMiscSLotConfigFromPcd ()
   SMBIOSlotConfig.SMBIOSSystemSlot[2].SlotId = PcdGet16(PcdSMBIOSSystemSlot3Id);
   SMBIOSlotConfig.SMBIOSSystemSlot[2].SlotCharacteristics = PcdGet32(PcdSMBIOSSystemSlot3Characteristics);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot4Designation), SMBIOSlotConfig.SMBIOSSystemSlot[3].SlotDesignation);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot4Designation), SMBIOSlotConfig.SMBIOSSystemSlot[3].SlotDesignation, ARRAY_SIZE (SMBIOSlotConfig.SMBIOSSystemSlot[3].SlotDesignation));
   SMBIOSlotConfig.SMBIOSSystemSlot[3].SlotType = PcdGet8(PcdSMBIOSSystemSlot4Type);
   SMBIOSlotConfig.SMBIOSSystemSlot[3].SlotDataBusWidth = PcdGet8(PcdSMBIOSSystemSlot4DataBusWidth);
   SMBIOSlotConfig.SMBIOSSystemSlot[3].SlotUsage = PcdGet8(PcdSMBIOSSystemSlot4Usage);
@@ -101,7 +101,7 @@ GetMiscSLotConfigFromPcd ()
   SMBIOSlotConfig.SMBIOSSystemSlot[3].SlotId = PcdGet16(PcdSMBIOSSystemSlot4Id);
   SMBIOSlotConfig.SMBIOSSystemSlot[3].SlotCharacteristics = PcdGet32(PcdSMBIOSSystemSlot4Characteristics);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot5Designation), SMBIOSlotConfig.SMBIOSSystemSlot[4].SlotDesignation);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot5Designation), SMBIOSlotConfig.SMBIOSSystemSlot[4].SlotDesignation, ARRAY_SIZE (SMBIOSlotConfig.SMBIOSSystemSlot[4].SlotDesignation));
   SMBIOSlotConfig.SMBIOSSystemSlot[4].SlotType = PcdGet8(PcdSMBIOSSystemSlot5Type);
   SMBIOSlotConfig.SMBIOSSystemSlot[4].SlotDataBusWidth = PcdGet8(PcdSMBIOSSystemSlot5DataBusWidth);
   SMBIOSlotConfig.SMBIOSSystemSlot[4].SlotUsage = PcdGet8(PcdSMBIOSSystemSlot5Usage);
@@ -109,7 +109,7 @@ GetMiscSLotConfigFromPcd ()
   SMBIOSlotConfig.SMBIOSSystemSlot[4].SlotId = PcdGet16(PcdSMBIOSSystemSlot5Id);
   SMBIOSlotConfig.SMBIOSSystemSlot[4].SlotCharacteristics = PcdGet32(PcdSMBIOSSystemSlot5Characteristics);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot6Designation), SMBIOSlotConfig.SMBIOSSystemSlot[5].SlotDesignation);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot6Designation), SMBIOSlotConfig.SMBIOSSystemSlot[5].SlotDesignation, ARRAY_SIZE (SMBIOSlotConfig.SMBIOSSystemSlot[5].SlotDesignation));
   SMBIOSlotConfig.SMBIOSSystemSlot[5].SlotType = PcdGet8(PcdSMBIOSSystemSlot6Type);
   SMBIOSlotConfig.SMBIOSSystemSlot[5].SlotDataBusWidth = PcdGet8(PcdSMBIOSSystemSlot6DataBusWidth);
   SMBIOSlotConfig.SMBIOSSystemSlot[5].SlotUsage = PcdGet8(PcdSMBIOSSystemSlot6Usage);
@@ -117,7 +117,7 @@ GetMiscSLotConfigFromPcd ()
   SMBIOSlotConfig.SMBIOSSystemSlot[5].SlotId = PcdGet16(PcdSMBIOSSystemSlot6Id);
   SMBIOSlotConfig.SMBIOSSystemSlot[5].SlotCharacteristics = PcdGet32(PcdSMBIOSSystemSlot6Characteristics);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot7Designation), SMBIOSlotConfig.SMBIOSSystemSlot[6].SlotDesignation);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot7Designation), SMBIOSlotConfig.SMBIOSSystemSlot[6].SlotDesignation, ARRAY_SIZE (SMBIOSlotConfig.SMBIOSSystemSlot[6].SlotDesignation));
   SMBIOSlotConfig.SMBIOSSystemSlot[6].SlotType = PcdGet8(PcdSMBIOSSystemSlot7Type);
   SMBIOSlotConfig.SMBIOSSystemSlot[6].SlotDataBusWidth = PcdGet8(PcdSMBIOSSystemSlot7DataBusWidth);
   SMBIOSlotConfig.SMBIOSSystemSlot[6].SlotUsage = PcdGet8(PcdSMBIOSSystemSlot7Usage);
@@ -125,7 +125,7 @@ GetMiscSLotConfigFromPcd ()
   SMBIOSlotConfig.SMBIOSSystemSlot[6].SlotId = PcdGet16(PcdSMBIOSSystemSlot7Id);
   SMBIOSlotConfig.SMBIOSSystemSlot[6].SlotCharacteristics = PcdGet32(PcdSMBIOSSystemSlot7Characteristics);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot8Designation), SMBIOSlotConfig.SMBIOSSystemSlot[7].SlotDesignation);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot8Designation), SMBIOSlotConfig.SMBIOSSystemSlot[7].SlotDesignation, ARRAY_SIZE (SMBIOSlotConfig.SMBIOSSystemSlot[7].SlotDesignation));
   SMBIOSlotConfig.SMBIOSSystemSlot[7].SlotType = PcdGet8(PcdSMBIOSSystemSlot8Type);
   SMBIOSlotConfig.SMBIOSSystemSlot[7].SlotDataBusWidth = PcdGet8(PcdSMBIOSSystemSlot8DataBusWidth);
   SMBIOSlotConfig.SMBIOSSystemSlot[7].SlotUsage = PcdGet8(PcdSMBIOSSystemSlot8Usage);
@@ -133,7 +133,7 @@ GetMiscSLotConfigFromPcd ()
   SMBIOSlotConfig.SMBIOSSystemSlot[7].SlotId = PcdGet16(PcdSMBIOSSystemSlot8Id);
   SMBIOSlotConfig.SMBIOSSystemSlot[7].SlotCharacteristics = PcdGet32(PcdSMBIOSSystemSlot8Characteristics);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot9Designation), SMBIOSlotConfig.SMBIOSSystemSlot[8].SlotDesignation);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot9Designation), SMBIOSlotConfig.SMBIOSSystemSlot[8].SlotDesignation, ARRAY_SIZE (SMBIOSlotConfig.SMBIOSSystemSlot[8].SlotDesignation));
   SMBIOSlotConfig.SMBIOSSystemSlot[8].SlotType = PcdGet8(PcdSMBIOSSystemSlot9Type);
   SMBIOSlotConfig.SMBIOSSystemSlot[8].SlotDataBusWidth = PcdGet8(PcdSMBIOSSystemSlot9DataBusWidth);
   SMBIOSlotConfig.SMBIOSSystemSlot[8].SlotUsage = PcdGet8(PcdSMBIOSSystemSlot9Usage);
@@ -141,7 +141,7 @@ GetMiscSLotConfigFromPcd ()
   SMBIOSlotConfig.SMBIOSSystemSlot[8].SlotId = PcdGet16(PcdSMBIOSSystemSlot9Id);
   SMBIOSlotConfig.SMBIOSSystemSlot[8].SlotCharacteristics = PcdGet32(PcdSMBIOSSystemSlot9Characteristics);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot10Designation), SMBIOSlotConfig.SMBIOSSystemSlot[9].SlotDesignation);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot10Designation), SMBIOSlotConfig.SMBIOSSystemSlot[9].SlotDesignation, ARRAY_SIZE (SMBIOSlotConfig.SMBIOSSystemSlot[9].SlotDesignation));
   SMBIOSlotConfig.SMBIOSSystemSlot[9].SlotType = PcdGet8(PcdSMBIOSSystemSlot10Type);
   SMBIOSlotConfig.SMBIOSSystemSlot[9].SlotDataBusWidth = PcdGet8(PcdSMBIOSSystemSlot10DataBusWidth);
   SMBIOSlotConfig.SMBIOSSystemSlot[9].SlotUsage = PcdGet8(PcdSMBIOSSystemSlot10Usage);
@@ -149,7 +149,7 @@ GetMiscSLotConfigFromPcd ()
   SMBIOSlotConfig.SMBIOSSystemSlot[9].SlotId = PcdGet16(PcdSMBIOSSystemSlot10Id);
   SMBIOSlotConfig.SMBIOSSystemSlot[9].SlotCharacteristics = PcdGet32(PcdSMBIOSSystemSlot10Characteristics);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot11Designation), SMBIOSlotConfig.SMBIOSSystemSlot[10].SlotDesignation);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot11Designation), SMBIOSlotConfig.SMBIOSSystemSlot[10].SlotDesignation, ARRAY_SIZE (SMBIOSlotConfig.SMBIOSSystemSlot[10].SlotDesignation));
   SMBIOSlotConfig.SMBIOSSystemSlot[10].SlotType = PcdGet8(PcdSMBIOSSystemSlot11Type);
   SMBIOSlotConfig.SMBIOSSystemSlot[10].SlotDataBusWidth = PcdGet8(PcdSMBIOSSystemSlot11DataBusWidth);
   SMBIOSlotConfig.SMBIOSSystemSlot[10].SlotUsage = PcdGet8(PcdSMBIOSSystemSlot11Usage);
@@ -157,7 +157,7 @@ GetMiscSLotConfigFromPcd ()
   SMBIOSlotConfig.SMBIOSSystemSlot[10].SlotId = PcdGet16(PcdSMBIOSSystemSlot11Id);
   SMBIOSlotConfig.SMBIOSSystemSlot[10].SlotCharacteristics = PcdGet32(PcdSMBIOSSystemSlot11Characteristics);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot12Designation), SMBIOSlotConfig.SMBIOSSystemSlot[11].SlotDesignation);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot12Designation), SMBIOSlotConfig.SMBIOSSystemSlot[11].SlotDesignation, ARRAY_SIZE (SMBIOSlotConfig.SMBIOSSystemSlot[11].SlotDesignation));
   SMBIOSlotConfig.SMBIOSSystemSlot[11].SlotType = PcdGet8(PcdSMBIOSSystemSlot12Type);
   SMBIOSlotConfig.SMBIOSSystemSlot[11].SlotDataBusWidth = PcdGet8(PcdSMBIOSSystemSlot12DataBusWidth);
   SMBIOSlotConfig.SMBIOSSystemSlot[11].SlotUsage = PcdGet8(PcdSMBIOSSystemSlot12Usage);
@@ -165,7 +165,7 @@ GetMiscSLotConfigFromPcd ()
   SMBIOSlotConfig.SMBIOSSystemSlot[11].SlotId = PcdGet16(PcdSMBIOSSystemSlot12Id);
   SMBIOSlotConfig.SMBIOSSystemSlot[11].SlotCharacteristics = PcdGet32(PcdSMBIOSSystemSlot12Characteristics);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot13Designation), SMBIOSlotConfig.SMBIOSSystemSlot[12].SlotDesignation);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot13Designation), SMBIOSlotConfig.SMBIOSSystemSlot[12].SlotDesignation, ARRAY_SIZE (SMBIOSlotConfig.SMBIOSSystemSlot[12].SlotDesignation));
   SMBIOSlotConfig.SMBIOSSystemSlot[12].SlotType = PcdGet8(PcdSMBIOSSystemSlot13Type);
   SMBIOSlotConfig.SMBIOSSystemSlot[12].SlotDataBusWidth = PcdGet8(PcdSMBIOSSystemSlot13DataBusWidth);
   SMBIOSlotConfig.SMBIOSSystemSlot[12].SlotUsage = PcdGet8(PcdSMBIOSSystemSlot13Usage);
@@ -173,7 +173,7 @@ GetMiscSLotConfigFromPcd ()
   SMBIOSlotConfig.SMBIOSSystemSlot[12].SlotId = PcdGet16(PcdSMBIOSSystemSlot13Id);
   SMBIOSlotConfig.SMBIOSSystemSlot[12].SlotCharacteristics = PcdGet32(PcdSMBIOSSystemSlot13Characteristics);
 
-  AsciiStrToUnicodeStr ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot14Designation), SMBIOSlotConfig.SMBIOSSystemSlot[13].SlotDesignation);
+  AsciiStrToUnicodeStrS ((CHAR8 *) PcdGetPtr(PcdSMBIOSSystemSlot14Designation), SMBIOSlotConfig.SMBIOSSystemSlot[13].SlotDesignation, ARRAY_SIZE (SMBIOSlotConfig.SMBIOSSystemSlot[13].SlotDesignation));
   SMBIOSlotConfig.SMBIOSSystemSlot[13].SlotType = PcdGet8(PcdSMBIOSSystemSlot14Type);
   SMBIOSlotConfig.SMBIOSSystemSlot[13].SlotDataBusWidth = PcdGet8(PcdSMBIOSSystemSlot14DataBusWidth);
   SMBIOSlotConfig.SMBIOSSystemSlot[13].SlotUsage = PcdGet8(PcdSMBIOSSystemSlot14Usage);
@@ -269,7 +269,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscSystemSlotDesignator)
   // Slot Characteristics
   //
   OptionalStrStart = (CHAR8 *)(SmbiosRecord + 1);
-  UnicodeStrToAsciiStr(SlotDesignation, OptionalStrStart);
+  UnicodeStrToAsciiStrS (SlotDesignation, OptionalStrStart, SlotDesignationStrLen + 1);
   //
   // Now we have got the full smbios record, call smbios protocol to add this record.
   //