]> git.proxmox.com Git - mirror_edk2.git/commitdiff
NetworkPkg: Fix incorrect unicode string of the AKM/Cipher Suite edk2-stable202202
authorHeng Luo <heng.luo@intel.com>
Wed, 26 Jan 2022 05:12:21 +0000 (13:12 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 21 Feb 2022 15:19:40 +0000 (15:19 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3813

The size of buffer should be 3 CHAR16 for Null-terminated Unicode
string.
The first char is the AKM/Cipher Suite number, the second char is ' ',
the third char is '\0'.

Cc: Maciej Rabeda <maciej.rabeda@linux.intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Signed-off-by: Heng Luo <heng.luo@intel.com>
Reviewed-by: Maciej Rabeda <maciej.rabeda@linux.intel.com>
NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrHiiConfigAccess.c

index b49825bcb7b11f4c799ec0cbfff36bdd5e5c1ee3..7cb2bfc281c4138789595eb596ef752061fccd43 100644 (file)
@@ -280,12 +280,16 @@ WifiMgrGetStrAKMList (
     //\r
     // Current AKM Suite is between 1-9\r
     //\r
-    AKMListDisplay = (CHAR16 *)AllocateZeroPool (sizeof (CHAR16) * AKMSuiteCount * 2);\r
+    AKMListDisplay = (CHAR16 *)AllocateZeroPool (sizeof (CHAR16) * (AKMSuiteCount * 2 + 1));\r
     if (AKMListDisplay != NULL) {\r
       for (Index = 0; Index < AKMSuiteCount; Index++) {\r
+        //\r
+        // The size of buffer should be 3 CHAR16 for Null-terminated Unicode string.\r
+        // The first char is the AKM Suite number, the second char is ' ', the third char is '\0'.\r
+        //\r
         UnicodeSPrint (\r
           AKMListDisplay + (Index * 2),\r
-          sizeof (CHAR16) * 2,\r
+          sizeof (CHAR16) * 3,\r
           L"%d ",\r
           Profile->Network.AKMSuite->AKMSuiteList[Index].SuiteType\r
           );\r
@@ -333,12 +337,16 @@ WifiMgrGetStrCipherList (
     //\r
     // Current Cipher Suite is between 1-9\r
     //\r
-    CipherListDisplay = (CHAR16 *)AllocateZeroPool (sizeof (CHAR16) * CipherSuiteCount * 2);\r
+    CipherListDisplay = (CHAR16 *)AllocateZeroPool (sizeof (CHAR16) * (CipherSuiteCount * 2 + 1));\r
     if (CipherListDisplay != NULL) {\r
       for (Index = 0; Index < CipherSuiteCount; Index++) {\r
+        //\r
+        // The size of buffer should be 3 CHAR16 for Null-terminated Unicode string.\r
+        // The first char is the Cipher Suite number, the second char is ' ', the third char is '\0'.\r
+        //\r
         UnicodeSPrint (\r
           CipherListDisplay + (Index * 2),\r
-          sizeof (CHAR16) * 2,\r
+          sizeof (CHAR16) * 3,\r
           L"%d ",\r
           Profile->Network.CipherSuite->CipherSuiteList[Index].SuiteType\r
           );\r