From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-CY1-obe.outbound.protection.outlook.com (mail-cys01nam02on0725.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe45::725]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BA48B1A1DF7 for ; Fri, 29 Jul 2016 15:27:31 -0700 (PDT) Received: from CS1PR84MB0151.NAMPRD84.PROD.OUTLOOK.COM (10.162.189.30) by CS1PR84MB0149.NAMPRD84.PROD.OUTLOOK.COM (10.162.189.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.549.15; Fri, 29 Jul 2016 22:27:30 +0000 Received: from CS1PR84MB0151.NAMPRD84.PROD.OUTLOOK.COM ([10.162.189.30]) by CS1PR84MB0151.NAMPRD84.PROD.OUTLOOK.COM ([10.162.189.30]) with mapi id 15.01.0549.016; Fri, 29 Jul 2016 22:27:29 +0000 From: "Palmer, Thomas" To: Jiaxin Wu , "edk2-devel@lists.01.org" CC: Samer El-Haj-Mahmoud , Long Qin , Ye Ting , Fu Siyuan Thread-Topic: [staging/HTTPS-TLS][PATCH 2/2] NetworkPkg: Fix potential assert issue Thread-Index: AQHR2zckYJImnE2H4EeDyd1x3MO21aAwGkrg Date: Fri, 29 Jul 2016 22:27:29 +0000 Message-ID: References: <1468215775-33448-1-git-send-email-jiaxin.wu@intel.com> <1468215775-33448-3-git-send-email-jiaxin.wu@intel.com> In-Reply-To: <1468215775-33448-3-git-send-email-jiaxin.wu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=thomas.palmer@hpe.com; x-originating-ip: [15.203.227.4] x-ms-office365-filtering-correlation-id: 4ccb5ec0-0f49-409a-3542-08d3b7ff86e2 x-microsoft-exchange-diagnostics: 1; CS1PR84MB0149; 6:Kv7Wc6S0RtntNYvGnlbQDqNq5wq/mNAWSCXEdrlHL/uA1fCrN4jd2N2u0awzd0OwWV+3mSzvNzz9FdTh5VerxmCzalXC5uSbvv/47rxIszJWdpPvGcBSB2neL1d1hgy0X8eNsnx0jhPqUTavCZyE0O/4ywDr4N6yYU4mQfWUfp/c+NkygyOo+h90qeXmjoDq4XNGGvcU23TIIVvlIlr3w7tDc97bWJftJ9uLJlhR9sk8bVFAR37Rk0DnW8Kyt4/5THqKTBxjrFUAhLL+QE1TMvcPrRbBo2UL+C7oXBP7lOj0mphtSPw6KbMKy36TzvC4ttV7ocV8QslPlI4oZUAEYw==; 5:Uld+tqYWd3QeRDpWZsAGgswAulhEA3vnM7Kl6Gt9LFJDa0ICqqkWCMSbDhpJOtR+TQxArP0o3LxJQ6LaeOe71TH34GgGjG9tYGhIXeJZ9/+sq8BXy4JRP0yaeme/8WN9rhFadQB3hYerW5h8tUJ7tA==; 24:dT2lFfWtppqIMqg0jm2eI/3AEsNyssx1dtJdZEyBTzGIv+IRe05YSWtUs50KVpxqDXfQrClH25moCJ6H3DnWd56y4OH2rpUOaiQbwL+tuEU=; 7:rfr+/hWavl7DL8kuzSywwCKdTvyZxRuByDDjbVlWT1JZaKxyytTdS9mA5Q/ClkualiVaIksAgiK5hpHzVs/azq9aCV19K62Xtr8U8E8ML9hzO9V6/04Jl09altne3FDwY9q/ZVC6Iq928SEeCCdMH1NtrmWfqulct4b1cfHbOQuqGp/bcXwuSNpN8/ddxRJW5EsNjXzgJOfKPFeCA0Bx4i/vA2UijM2XovqR2YzjZDcIaILpq5R732Q5HRj1WbUI x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CS1PR84MB0149; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(227479698468861)(3940261145250)(162533806227266)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026); SRVR:CS1PR84MB0149; BCL:0; PCL:0; RULEID:; SRVR:CS1PR84MB0149; x-forefront-prvs: 0018A2705B x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(7916002)(377454003)(189002)(199003)(13464003)(8676002)(2900100001)(3280700002)(106356001)(81156014)(74316002)(106116001)(33656002)(97736004)(2501003)(189998001)(77096005)(3660700001)(8936002)(5001770100001)(4326007)(86362001)(2906002)(81166006)(2950100001)(87936001)(305945005)(92566002)(7736002)(586003)(66066001)(122556002)(9686002)(19580395003)(68736007)(6116002)(19580405001)(10400500002)(102836003)(3846002)(5002640100001)(54356999)(105586002)(99286002)(101416001)(7696003)(76176999)(50986999)(7846002); DIR:OUT; SFP:1102; SCL:1; SRVR:CS1PR84MB0149; H:CS1PR84MB0151.NAMPRD84.PROD.OUTLOOK.COM; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: hpe.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: hpe.com X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jul 2016 22:27:29.5656 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 105b2061-b669-4b31-92ac-24d304d195dc X-MS-Exchange-Transport-CrossTenantHeadersStamped: CS1PR84MB0149 Subject: Re: [staging/HTTPS-TLS][PATCH 2/2] NetworkPkg: Fix potential assert issue X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jul 2016 22:27:32 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed by Thomas Palmer -----Original Message----- From: Jiaxin Wu [mailto:jiaxin.wu@intel.com]=20 Sent: Monday, July 11, 2016 12:43 AM To: edk2-devel@lists.01.org Cc: Palmer, Thomas ; Samer El-Haj-Mahmoud ; Long Qin ; Ye Ting ; Fu= Siyuan Subject: [staging/HTTPS-TLS][PATCH 2/2] NetworkPkg: Fix potential assert is= sue This patch is used to fix potential assert issue when connection failed or = buffer allocation failed. Cc: Palmer Thomas Cc: Samer El-Haj-Mahmoud Cc: Long Qin Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiaxin Wu --- NetworkPkg/HttpDxe/HttpsSupport.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/NetworkPkg/HttpDxe/HttpsSupport.c b/NetworkPkg/HttpDxe/HttpsSu= pport.c index 36f658c..d746972 100644 --- a/NetworkPkg/HttpDxe/HttpsSupport.c +++ b/NetworkPkg/HttpDxe/HttpsSupport.c @@ -874,11 +874,14 @@ TlsReceiveOnePdu ( Status =3D EFI_OUT_OF_RESOURCES; goto ON_EXIT; } =20 Header =3D NetbufAllocSpace (PduHdr, Len, NET_BUF_TAIL); - ASSERT (Header !=3D NULL); + if (Header =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto ON_EXIT; + } =20 // // First step, receive one TLS header. // Status =3D TlsCommonReceive (HttpInstance, PduHdr, Timeout); @@ -899,12 = +902,10 @@ TlsReceiveOnePdu ( InsertTailList (NbufList, &PduHdr->List); } else { Status =3D EFI_PROTOCOL_ERROR; goto ON_EXIT; } - - ASSERT(Header !=3D NULL); =20 Len =3D SwapBytes16(RecordHeader.Length); if (Len =3D=3D 0) { // // No TLS playload. @@ -1184,11 +1185,13 @@ TlsConnectSession ( if(HttpInstance->TlsSessionState =3D=3D EfiTlsSessionError) { =20 return EFI_ABORTED; =20 } } =20 - ASSERT(HttpInstance->TlsSessionState =3D=3D EfiTlsSessionDataTransferrin= g); + if (HttpInstance->TlsSessionState !=3D EfiTlsSessionDataTransferring) { + Status =3D EFI_ABORTED; + } =20 return Status; } =20 /** @@ -1572,11 +1575,14 @@ HttpsReceive ( // ASSERT (((TLSRecordHeader *) (TempFragment.Bulk))->ContentType =3D=3D = TLS_CONTENT_TYPE_APPLICATION_DATA); =20 BufferInSize =3D ((TLSRecordHeader *) (TempFragment.Bulk))->Length; BufferIn =3D AllocateZeroPool (BufferInSize); - ASSERT (BufferIn !=3D NULL); + if (BufferIn =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + return Status; + } =20 CopyMem (BufferIn, TempFragment.Bulk + sizeof (TLSRecordHeader), Buffe= rInSize); =20 // // Free the buffer in TempFragment. -- 1.9.5.msysgit.1