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.20; helo=mga02.intel.com; envelope-from=qin.long@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 C2C11221ED77E for ; Wed, 20 Dec 2017 23:54:53 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Dec 2017 23:59:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,434,1508828400"; d="scan'208";a="20075210" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga002.jf.intel.com with ESMTP; 20 Dec 2017 23:59:41 -0800 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 20 Dec 2017 23:59:41 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 20 Dec 2017 23:59:41 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.152]) with mapi id 14.03.0319.002; Thu, 21 Dec 2017 15:59:39 +0800 From: "Long, Qin" To: "Wu, Jiaxin" , "edk2-devel@lists.01.org" CC: "Ye, Ting" , "Fu, Siyuan" Thread-Topic: [Patch] CryptoPkg/TlsLib: Add some parameter check and clarification. Thread-Index: AQHTehrpZqx7uHRz/EGSBUkwniuprqNNbv9A Date: Thu, 21 Dec 2017 07:59:39 +0000 Message-ID: References: <1513833401-13644-1-git-send-email-jiaxin.wu@intel.com> In-Reply-To: <1513833401-13644-1-git-send-email-jiaxin.wu@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] CryptoPkg/TlsLib: Add some parameter check and clarification. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Dec 2017 07:54:54 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Long Qin Best Regards & Thanks, LONG, Qin -----Original Message----- From: Wu, Jiaxin=20 Sent: Thursday, December 21, 2017 1:17 PM To: edk2-devel@lists.01.org Cc: Ye, Ting ; Long, Qin ; Fu, Siyua= n ; Wu, Jiaxin Subject: [Patch] CryptoPkg/TlsLib: Add some parameter check and clarificati= on. Cc: Ye Ting Cc: Long Qin Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin --- CryptoPkg/Include/Library/TlsLib.h | 6 ++++++ CryptoPkg/Library/TlsLib/TlsConfig.c | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CryptoPkg/Include/Library/TlsLib.h b/CryptoPkg/Include/Library= /TlsLib.h index b69d513..e19a38a 100644 --- a/CryptoPkg/Include/Library/TlsLib.h +++ b/CryptoPkg/Include/Library/TlsLib.h @@ -521,10 +521,12 @@ TlsSetCertRevocationList ( Gets the protocol version used by the specified TLS connection. =20 This function returns the protocol version used by the specified TLS connection. =20 + If Tls is NULL, then ASSERT(). + @param[in] Tls Pointer to the TLS object. =20 @return The protocol version of the specified TLS connection. =20 **/ @@ -538,10 +540,12 @@ TlsGetVersion ( Gets the connection end of the specified TLS connection. =20 This function returns the connection end (as client or as server) used b= y the specified TLS connection. =20 + If Tls is NULL, then ASSERT(). + @param[in] Tls Pointer to the TLS object. =20 @return The connection end used by the specified TLS connection. =20 **/ @@ -599,10 +603,12 @@ TlsGetCurrentCompressionId ( Gets the verification mode currently set in the TLS connection. =20 This function returns the peer verification mode currently set in the specified TLS connection. =20 + If Tls is NULL, then ASSERT(). + @param[in] Tls Pointer to the TLS object. =20 @return The verification mode set in the specified TLS connection. =20 **/ diff --git a/CryptoPkg/Library/TlsLib/TlsConfig.c b/CryptoPkg/Library/TlsLi= b/TlsConfig.c index 4c88229..2ffe58a 100644 --- a/CryptoPkg/Library/TlsLib/TlsConfig.c +++ b/CryptoPkg/Library/TlsLib/TlsConfig.c @@ -640,10 +640,12 @@ TlsSetCertRevocationList ( Gets the protocol version used by the specified TLS connection. =20 This function returns the protocol version used by the specified TLS connection. =20 + If Tls is NULL, then ASSERT(). + @param[in] Tls Pointer to the TLS object. =20 @return The protocol version of the specified TLS connection. =20 **/ @@ -666,10 +668,12 @@ TlsGetVersion ( Gets the connection end of the specified TLS connection. =20 This function returns the connection end (as client or as server) used b= y the specified TLS connection. =20 + If Tls is NULL, then ASSERT(). + @param[in] Tls Pointer to the TLS object. =20 @return The connection end used by the specified TLS connection. =20 **/ @@ -759,10 +763,12 @@ TlsGetCurrentCompressionId ( Gets the verification mode currently set in the TLS connection. =20 This function returns the peer verification mode currently set in the specified TLS connection. =20 + If Tls is NULL, then ASSERT(). + @param[in] Tls Pointer to the TLS object. =20 @return The verification mode set in the specified TLS connection. =20 **/ @@ -982,11 +988,11 @@ TlsGetHostPublicCert ( TLS_CONNECTION *TlsConn; =20 Cert =3D NULL; TlsConn =3D (TLS_CONNECTION *) Tls; =20 - if (TlsConn =3D=3D NULL || TlsConn->Ssl =3D=3D NULL || DataSize =3D=3D N= ULL) { + if (TlsConn =3D=3D NULL || TlsConn->Ssl =3D=3D NULL || DataSize =3D=3D N= ULL || (*DataSize !=3D 0 && Data =3D=3D NULL)) { return EFI_INVALID_PARAMETER; } =20 Cert =3D SSL_get_certificate(TlsConn->Ssl); if (Cert =3D=3D NULL) { --=20 1.9.5.msysgit.1