From nobody Thu May 16 14:04:38 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+106337+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+106337+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1687758045; cv=none; d=zohomail.com; s=zohoarc; b=oCsKjTNye+qXbPpj0h/BOypcbK4ib+oCpBmMPFGUdIVAl/Ew4e8UDmmbn+/6B8WlmNkAU0CUl8mWVWDP3qIrhduHbPXygCsZQWtpQQSggMcY3X9H3lPFljDq23mmBuSIcakAmoCvojSQ6oniTd8DBBaiG8RBtKkrpmklqA9IAxg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1687758045; 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=NV+VO0HCA2CC0SYuPXUbTUHSKepn5N8u4/CdPFXlqyA=; b=lE2/RlMHDHaRIrSZXOskljA9d35zMoWCcfyevSg/nmjRwDOdinN3McFSlFC8wXHiaSYymhn/CM9eknKajtStTMMnjBRXhObuCxb4Ou3dZM16Pa0gTzj4Ml4/vZtCNljCdk8XomA3SX+Wbj6MRJvpEDhX0QqCZ2Ef0fm3o8y5/9E= 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+106337+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 1687758045202784.9022290765975; Sun, 25 Jun 2023 22:40:45 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id yhoxYY1788612xq3Ozofy1UH; Sun, 25 Jun 2023 22:40:44 -0700 X-Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web11.1669.1687758043426233141 for ; Sun, 25 Jun 2023 22:40:44 -0700 X-IronPort-AV: E=McAfee;i="6600,9927,10752"; a="424850625" X-IronPort-AV: E=Sophos;i="6.01,158,1684825200"; d="scan'208";a="424850625" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2023 22:40:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10752"; a="710108524" X-IronPort-AV: E=Sophos;i="6.01,158,1684825200"; d="scan'208";a="710108524" X-Received: from liyi4-desktop.ccr.corp.intel.com ([10.239.153.10]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2023 22:40:41 -0700 From: "Li, Yi" To: devel@edk2.groups.io Cc: Yi Li , Maciej Rabeda , Zachary Clark-Williams Subject: [edk2-devel] [PATCH V3] NetworkPkg: Correct the length of EAP Identity when in ASCII format Date: Mon, 26 Jun 2023 13:40:34 +0800 Message-Id: <20230626054034.2346-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: GCsyqiuQk5sM5RN1cOLbTxqDx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1687758044; bh=Szkr16dAjW2NNGZVLG8cwyQoQDstbd71vYTuVwTs5ac=; h=Cc:Date:From:Reply-To:Subject:To; b=HQpJ2ebdXC224AE37tZhMs31rWxZZeh3BnmCham7bW/hPoqqGH+6PN9uudTrtFKPs56 CNv/UcIsnuplAO1QwCyl4td3NdtBlASBvkg8qtS1OfC3ftuj3PVE7jgQjd5slfAng9kOw NTNXD2C7cula6rm5BckAih1nM0BvbBzqX+4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1687758047208100003 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: Zachary Clark-Williams Signed-off-by: Yi Li Reviewed-by: Zachary Clark-Williams --- .../WifiConnectionMgrImpl.c | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c b/= NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c index 2e596c1981..d1182e52bd 100644 --- a/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c +++ b/NetworkPkg/WifiConnectionManagerDxe/WifiConnectionMgrImpl.c @@ -572,15 +572,28 @@ 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 (#106337): https://edk2.groups.io/g/devel/message/106337 Mute This Topic: https://groups.io/mt/99782400/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-