CryptoPkg/TlsLib: Add some parameter check and clarification.
authorJiaxin Wu <jiaxin.wu@intel.com>
Thu, 21 Dec 2017 05:08:31 +0000 (13:08 +0800)
committerJiaxin Wu <jiaxin.wu@intel.com>
Fri, 22 Dec 2017 07:50:37 +0000 (15:50 +0800)
Cc: Ye Ting <ting.ye@intel.com>
Cc: Long Qin <qin.long@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Long Qin <qin.long@intel.com>
CryptoPkg/Include/Library/TlsLib.h
CryptoPkg/Library/TlsLib/TlsConfig.c

index b69d5132850a34ab1770a361778d73a94a23b99c..e19a38a214ce687d216828cd23227570df3ddd9d 100644 (file)
@@ -523,6 +523,8 @@ TlsSetCertRevocationList (
   This function returns the protocol version used by the specified TLS\r
   connection.\r
 \r
+  If Tls is NULL, then ASSERT().\r
+\r
   @param[in]  Tls    Pointer to the TLS object.\r
 \r
   @return  The protocol version of the specified TLS connection.\r
@@ -540,6 +542,8 @@ TlsGetVersion (
   This function returns the connection end (as client or as server) used by\r
   the specified TLS connection.\r
 \r
+  If Tls is NULL, then ASSERT().\r
+\r
   @param[in]  Tls    Pointer to the TLS object.\r
 \r
   @return  The connection end used by the specified TLS connection.\r
@@ -601,6 +605,8 @@ TlsGetCurrentCompressionId (
   This function returns the peer verification mode currently set in the\r
   specified TLS connection.\r
 \r
+  If Tls is NULL, then ASSERT().\r
+\r
   @param[in]  Tls    Pointer to the TLS object.\r
 \r
   @return  The verification mode set in the specified TLS connection.\r
index 4c88229b8921492a55623393390cd4290d5c0544..2ffe58ad29a23f4389e80a01591db1c669278668 100644 (file)
@@ -642,6 +642,8 @@ TlsSetCertRevocationList (
   This function returns the protocol version used by the specified TLS\r
   connection.\r
 \r
+  If Tls is NULL, then ASSERT().\r
+\r
   @param[in]  Tls    Pointer to the TLS object.\r
 \r
   @return  The protocol version of the specified TLS connection.\r
@@ -668,6 +670,8 @@ TlsGetVersion (
   This function returns the connection end (as client or as server) used by\r
   the specified TLS connection.\r
 \r
+  If Tls is NULL, then ASSERT().\r
+\r
   @param[in]  Tls    Pointer to the TLS object.\r
 \r
   @return  The connection end used by the specified TLS connection.\r
@@ -761,6 +765,8 @@ TlsGetCurrentCompressionId (
   This function returns the peer verification mode currently set in the\r
   specified TLS connection.\r
 \r
+  If Tls is NULL, then ASSERT().\r
+\r
   @param[in]  Tls    Pointer to the TLS object.\r
 \r
   @return  The verification mode set in the specified TLS connection.\r
@@ -984,7 +990,7 @@ TlsGetHostPublicCert (
   Cert    = NULL;\r
   TlsConn = (TLS_CONNECTION *) Tls;\r
 \r
-  if (TlsConn == NULL || TlsConn->Ssl == NULL || DataSize == NULL) {\r
+  if (TlsConn == NULL || TlsConn->Ssl == NULL || DataSize == NULL || (*DataSize != 0 && Data == NULL)) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r