From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web12.8753.1643173958034354204 for ; Tue, 25 Jan 2022 21:12:38 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=KJK+jcgY; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: heng.luo@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1643173958; x=1674709958; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Y3O1MQmqiT22bgxG9najwcosZtFlxiUJCENHWNGEVYg=; b=KJK+jcgYjAUeP53Ox6cyfM78Ir2mbJ2Dv25WOKIYV3ui+ahw8BX6uYS6 LzTIahxfrfTdJQ7TYSgXqB9IIT7lEKHtqPuRZ6acPFSz7/SI66M1rW8us 1lKh/XCIgt/L5qLFFIfkEr7gVgJwW2MAmoKCZ6yOVcd3zks5FPW/NJLxG qDZJs0Qued7AUS0Yx+MzVEYu7ex1PHEhr5sO7YeOOt4tnQ1pr6Hfo6fBx sRDIGvO9/G5cs07rrMHvj17gEO7N0i15cQ2woDeo41Tvjwcqi8uC4cAIw YLSD5M5rW3kwYKjFx+NOM8BJBDMEhvHJiO/45BgWIhcEVAJYRSPAvlqk6 g==; X-IronPort-AV: E=McAfee;i="6200,9189,10238"; a="245314937" X-IronPort-AV: E=Sophos;i="5.88,316,1635231600"; d="scan'208";a="245314937" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jan 2022 21:12:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,316,1635231600"; d="scan'208";a="479773396" Received: from hengluo-dev.ccr.corp.intel.com ([10.239.153.139]) by orsmga006.jf.intel.com with ESMTP; 25 Jan 2022 21:12:35 -0800 From: "Heng Luo" To: devel@edk2.groups.io Cc: Maciej Rabeda , Fu Siyuan , Wu Jiaxin Subject: [PATCH] NetworkPkg: Fix incorrect unicode string of the AKM/Cipher Suite Date: Wed, 26 Jan 2022 13:12:21 +0800 Message-Id: <20220126051221.3772-1-heng.luo@intel.com> X-Mailer: git-send-email 2.31.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Cc: Fu Siyuan Cc: Wu Jiaxin Signed-off-by: Heng Luo --- NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrHiiConfigAccess.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrHiiConfigAccess.c b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrHiiConfigAccess.c index b49825bcb7..7cb2bfc281 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrHiiConfigAccess.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrHiiConfigAccess.c @@ -280,12 +280,16 @@ WifiMgrGetStrAKMList ( // // Current AKM Suite is between 1-9 // - AKMListDisplay = (CHAR16 *)AllocateZeroPool (sizeof (CHAR16) * AKMSuiteCount * 2); + AKMListDisplay = (CHAR16 *)AllocateZeroPool (sizeof (CHAR16) * (AKMSuiteCount * 2 + 1)); if (AKMListDisplay != NULL) { for (Index = 0; Index < AKMSuiteCount; Index++) { + // + // The size of buffer should be 3 CHAR16 for Null-terminated Unicode string. + // The first char is the AKM Suite number, the second char is ' ', the third char is '\0'. + // UnicodeSPrint ( AKMListDisplay + (Index * 2), - sizeof (CHAR16) * 2, + sizeof (CHAR16) * 3, L"%d ", Profile->Network.AKMSuite->AKMSuiteList[Index].SuiteType ); @@ -333,12 +337,16 @@ WifiMgrGetStrCipherList ( // // Current Cipher Suite is between 1-9 // - CipherListDisplay = (CHAR16 *)AllocateZeroPool (sizeof (CHAR16) * CipherSuiteCount * 2); + CipherListDisplay = (CHAR16 *)AllocateZeroPool (sizeof (CHAR16) * (CipherSuiteCount * 2 + 1)); if (CipherListDisplay != NULL) { for (Index = 0; Index < CipherSuiteCount; Index++) { + // + // The size of buffer should be 3 CHAR16 for Null-terminated Unicode string. + // The first char is the Cipher Suite number, the second char is ' ', the third char is '\0'. + // UnicodeSPrint ( CipherListDisplay + (Index * 2), - sizeof (CHAR16) * 2, + sizeof (CHAR16) * 3, L"%d ", Profile->Network.CipherSuite->CipherSuiteList[Index].SuiteType ); -- 2.31.1.windows.1