From nobody Thu May 16 07:27:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+106185+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+106185+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1687236446; cv=none; d=zohomail.com; s=zohoarc; b=QYp/aYz2dlFsoapIx8xYLvAlym8SQKrwJvZZWTfr1vKhrZfvLfiLsl2648UXOKByyOnJWm/v7ZwfWq2OMMBT+t3r4+rP7RY53S83W8VOHqe2+Z76QnpJHmgt6qBcGcn2MmVpMyfxRjIGAyj1maqy+KoD1pRsHR1MsQzWUcG0Dws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687236446; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=snuuNA8u2UTzpzbJfm0lAC7JLTgyiFgaW01pOsiupRk=; b=JhXirttl1c61QeTpVfKMCswWF8bFNQ7PuSiHt+5x2AguOK69oDJWkPzjv+fb2fFG3lLWmrVYp02nidabpnZlRRZOiy4FUCu1ljvHHtZB+4Yt4lqvinKFL+ng4CC/bRBo5NRhZGZaV5K1M+USrCXy5YMTPu+oWE5KZd9tjXHu+Bk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+106185+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16872364462855.500997609354158; Mon, 19 Jun 2023 21:47:26 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id gNw0YY1788612x1zAR4TQZfe; Mon, 19 Jun 2023 21:47:25 -0700 X-Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mx.groups.io with SMTP id smtpd.web10.3491.1687236444538221753 for ; Mon, 19 Jun 2023 21:47:25 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10746"; a="388932615" X-IronPort-AV: E=Sophos;i="6.00,256,1681196400"; d="scan'208";a="388932615" X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2023 21:47:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10746"; a="664149710" X-IronPort-AV: E=Sophos;i="6.00,256,1681196400"; d="scan'208";a="664149710" X-Received: from liyi4-desktop.ccr.corp.intel.com ([10.239.153.10]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jun 2023 21:47:21 -0700 From: "Li, Yi" To: devel@edk2.groups.io Cc: Yi Li , Maciej Rabeda , Siyuan Fu , Zachary Clark-Williams Subject: [edk2-devel] [PATCH V2] NetworkPkg: Correct the length of EAP Identity when in ASCII format Date: Tue, 20 Jun 2023 12:35:34 +0800 Message-Id: <20230620043534.18380-1-yi1.li@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,yi1.li@intel.com X-Gm-Message-State: UE1BeoC940sJesryoiPDz1Smx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1687236445; bh=jn9VzbJ9nPlECNAUFyFQqpk9hgK2T8tpFvdSl8GE5oU=; h=Cc:Date:From:Reply-To:Subject:To; b=ar6U+UjOIG72QJqmbP9k0aKAg7AecUOvR9tHwfLjBVyplqkD1wB9gcdeRPoaCDpZmNc FUC47tBTY27nAHaORNqSMfRH2i1NEQsWI9gv//9l0aO4q8xmjFFio4CcHjjnVOyZm6lgP 3Fl4dxqMFy8kI2Rp8m+fEGnR/EiIbh4rZMs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1687236446952100001 Content-Type: text/plain; charset="utf-8" FIX: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4477 Tls connection fail over WiFi in AMT OCR flow due to invalid identity. This was due to missing conversion between unicode and ascii string which resulted in invalid strlen. Cc: Maciej Rabeda Cc: Siyuan Fu Cc: Zachary Clark-Williams Signed-off-by: Yi Li --- .../WifiConnectionMgrImpl.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c b/= NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c index 2e596c1981..1441ceed60 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c @@ -572,15 +572,24 @@ WifiMgrConfigEap ( // Set Identity to Eap peer, Mandatory field for PEAP and TTLS // if (StrLen (Profile->EapIdentity) > 0) { - IdentitySize =3D sizeof (CHAR8) * (StrLen (Profile->EapIdentity) + 1); - Identity =3D AllocateZeroPool (IdentitySize); + Status =3D gBS->LocateProtocol (&gEdkiiWiFiProfileSyncProtocolGuid, NU= LL, (VOID **)&WiFiProfileSyncProtocol); + if (!EFI_ERROR (Status)) { + /* Max size of EapIdentity ::=3D sizeof (CHAR16) * sizeof (Profile->= EapIdentity) ::=3D 2 * EAP_IDENTITY_SIZE */ + IdentitySize =3D sizeof (CHAR8) * (AsciiStrnLenS ((CHAR8 *)Profile->= EapIdentity, sizeof (CHAR16) * sizeof (Profile->EapIdentity)) + 1); + } else { + IdentitySize =3D sizeof (CHAR8) * (StrLen (Profile->EapIdentity) + 1= ); + } + + Identity =3D AllocateZeroPool (IdentitySize); if (Identity =3D=3D NULL) { return EFI_OUT_OF_RESOURCES; } =20 - Status =3D gBS->LocateProtocol (&gEdkiiWiFiProfileSyncProtocolGuid, NU= LL, (VOID **)&WiFiProfileSyncProtocol); if (!EFI_ERROR (Status)) { - CopyMem (Identity, &Profile->EapIdentity, IdentitySize); + /* The size of Identity from Username may equal + to the max size of EapIdentity(EAP_IDENTITY_SIZE*2=3D128 bytes), + so here only valid characters except NULL characters are copied. = */ + CopyMem (Identity, &Profile->EapIdentity, IdentitySize - 1); } else { UnicodeStrToAsciiStrS (Profile->EapIdentity, Identity, IdentitySize); } --=20 2.31.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#106185): https://edk2.groups.io/g/devel/message/106185 Mute This Topic: https://groups.io/mt/99638708/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-