From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=siyuan.fu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 86A1721F2E0EA for ; Mon, 9 Apr 2018 18:53:50 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Apr 2018 18:53:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,429,1517904000"; d="scan'208";a="190171166" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga004.jf.intel.com with ESMTP; 09 Apr 2018 18:53:49 -0700 Received: from fmsmsx125.amr.corp.intel.com (10.18.125.40) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 9 Apr 2018 18:53:44 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX125.amr.corp.intel.com (10.18.125.40) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 9 Apr 2018 18:53:44 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.151]) by shsmsx102.ccr.corp.intel.com ([169.254.2.184]) with mapi id 14.03.0319.002; Tue, 10 Apr 2018 09:53:42 +0800 From: "Fu, Siyuan" To: Laszlo Ersek , edk2-devel-01 CC: "Wu, Jiaxin" Thread-Topic: [PATCH 04/13] NetworkPkg/TlsDxe: clean up byte order conversion for EfiTlsCipherList Thread-Index: AQHTy1tbeggR9ftNH0mfbRkCuc4DsaP5Rr4w Date: Tue, 10 Apr 2018 01:53:41 +0000 Message-ID: References: <20180403145149.8925-1-lersek@redhat.com> <20180403145149.8925-5-lersek@redhat.com> In-Reply-To: <20180403145149.8925-5-lersek@redhat.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMDdjNDBlNzktNDA5NC00NDFmLWIyMDktM2JhNWU3YWFkYmE3IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJzQTlyUlluTDBcL1dXYml1SDVudHRxVGdHTlVzZmxSSmo5WDhXOGdKZEQzcDh3MkJMZmlCZ1wveDMzVmZ1K0o4Zm8ifQ== dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 04/13] NetworkPkg/TlsDxe: clean up byte order conversion for EfiTlsCipherList X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Apr 2018 01:53:50 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Fu Siyuan > -----Original Message----- > From: Laszlo Ersek [mailto:lersek@redhat.com] > Sent: Tuesday, April 3, 2018 10:52 PM > To: edk2-devel-01 > Cc: Wu, Jiaxin ; Fu, Siyuan > Subject: [PATCH 04/13] NetworkPkg/TlsDxe: clean up byte order conversion > for EfiTlsCipherList >=20 > Fix the following style issues: >=20 > - "Data" is accessed through a pointer to UINT16 rather than to a pointer > to EFI_TLS_CIPHER. While technically correct, UINT16 is harder to > interpret against the UEFI spec. >=20 > - Array subscripting is written with weird *(Pointer + Offset) > expressions, rather than with Pointer[Offset]. >=20 > - The byte order is converted with HTONS(), while it should be NTOHS(). > Either way, use the Data1 and Data2 fields of EFI_TLS_CIPHER instead. >=20 > Cc: Jiaxin Wu > Cc: Siyuan Fu > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D915 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Laszlo Ersek > --- > NetworkPkg/TlsDxe/TlsProtocol.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) >=20 > diff --git a/NetworkPkg/TlsDxe/TlsProtocol.c > b/NetworkPkg/TlsDxe/TlsProtocol.c > index a5f95a098345..298ffdd659a2 100644 > --- a/NetworkPkg/TlsDxe/TlsProtocol.c > +++ b/NetworkPkg/TlsDxe/TlsProtocol.c > @@ -57,12 +57,13 @@ TlsSetSessionData ( > IN UINTN DataSize > ) > { > EFI_STATUS Status; > TLS_INSTANCE *Instance; > UINT16 *CipherId; > + CONST EFI_TLS_CIPHER *TlsCipherList; > UINTN CipherCount; > UINTN Index; >=20 > EFI_TPL OldTpl; >=20 > Status =3D EFI_SUCCESS; > @@ -110,15 +111,17 @@ TlsSetSessionData ( > CipherId =3D AllocatePool (DataSize); > if (CipherId =3D=3D NULL) { > Status =3D EFI_OUT_OF_RESOURCES; > goto ON_EXIT; > } >=20 > + TlsCipherList =3D (CONST EFI_TLS_CIPHER *) Data; > CipherCount =3D DataSize / sizeof (EFI_TLS_CIPHER); > for (Index =3D 0; Index < CipherCount; Index++) { > - *(CipherId +Index) =3D HTONS (*(((UINT16 *) Data) + Index)); > + CipherId[Index] =3D ((TlsCipherList[Index].Data1 << 8) | > + TlsCipherList[Index].Data2); > } >=20 > Status =3D TlsSetCipherList (Instance->TlsConn, CipherId, CipherCoun= t); >=20 > FreePool (CipherId); > break; > -- > 2.14.1.3.gb7cf6e02401b >=20