From 9c14f76bae256820993e060461bc036b82634700 Mon Sep 17 00:00:00 2001 From: Jiaxin Wu Date: Thu, 21 Dec 2017 13:08:31 +0800 Subject: [PATCH] CryptoPkg/TlsLib: Add some parameter check and clarification. Cc: Ye Ting Cc: Long Qin Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin Reviewed-by: Long Qin --- 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 b69d513285..e19a38a214 100644 --- a/CryptoPkg/Include/Library/TlsLib.h +++ b/CryptoPkg/Include/Library/TlsLib.h @@ -523,6 +523,8 @@ TlsSetCertRevocationList ( This function returns the protocol version used by the specified TLS connection. + If Tls is NULL, then ASSERT(). + @param[in] Tls Pointer to the TLS object. @return The protocol version of the specified TLS connection. @@ -540,6 +542,8 @@ TlsGetVersion ( This function returns the connection end (as client or as server) used by the specified TLS connection. + If Tls is NULL, then ASSERT(). + @param[in] Tls Pointer to the TLS object. @return The connection end used by the specified TLS connection. @@ -601,6 +605,8 @@ TlsGetCurrentCompressionId ( This function returns the peer verification mode currently set in the specified TLS connection. + If Tls is NULL, then ASSERT(). + @param[in] Tls Pointer to the TLS object. @return The verification mode set in the specified TLS connection. diff --git a/CryptoPkg/Library/TlsLib/TlsConfig.c b/CryptoPkg/Library/TlsLib/TlsConfig.c index 4c88229b89..2ffe58ad29 100644 --- a/CryptoPkg/Library/TlsLib/TlsConfig.c +++ b/CryptoPkg/Library/TlsLib/TlsConfig.c @@ -642,6 +642,8 @@ TlsSetCertRevocationList ( This function returns the protocol version used by the specified TLS connection. + If Tls is NULL, then ASSERT(). + @param[in] Tls Pointer to the TLS object. @return The protocol version of the specified TLS connection. @@ -668,6 +670,8 @@ TlsGetVersion ( This function returns the connection end (as client or as server) used by the specified TLS connection. + If Tls is NULL, then ASSERT(). + @param[in] Tls Pointer to the TLS object. @return The connection end used by the specified TLS connection. @@ -761,6 +765,8 @@ TlsGetCurrentCompressionId ( This function returns the peer verification mode currently set in the specified TLS connection. + If Tls is NULL, then ASSERT(). + @param[in] Tls Pointer to the TLS object. @return The verification mode set in the specified TLS connection. @@ -984,7 +990,7 @@ TlsGetHostPublicCert ( Cert = NULL; TlsConn = (TLS_CONNECTION *) Tls; - if (TlsConn == NULL || TlsConn->Ssl == NULL || DataSize == NULL) { + if (TlsConn == NULL || TlsConn->Ssl == NULL || DataSize == NULL || (*DataSize != 0 && Data == NULL)) { return EFI_INVALID_PARAMETER; } -- 2.39.2