From 5a5e8584f9c68fc0ac6416558c91232bbd076c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Obiltschnig?= Date: Fri, 13 Mar 2020 09:33:08 +0100 Subject: [PATCH] NetSSL_Win: fix potential endless loop due to wrong error handling --- NetSSL_Win/src/SecureSocketImpl.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/NetSSL_Win/src/SecureSocketImpl.cpp b/NetSSL_Win/src/SecureSocketImpl.cpp index 8bcaa7516..7eff2838c 100644 --- a/NetSSL_Win/src/SecureSocketImpl.cpp +++ b/NetSSL_Win/src/SecureSocketImpl.cpp @@ -552,10 +552,10 @@ SECURITY_STATUS SecureSocketImpl::decodeMessage(BYTE* pBuffer, DWORD bufSize, Au { for (int i = 1; i < 4; ++i) { - if (pDataBuffer == 0 && msg[i].BufferType == SECBUFFER_DATA) + if (!pDataBuffer && msg[i].BufferType == SECBUFFER_DATA) pDataBuffer = &msg[i]; - if (pExtraBuffer == NULL && msg[i].BufferType == SECBUFFER_EXTRA) + if (!pExtraBuffer && msg[i].BufferType == SECBUFFER_EXTRA) pExtraBuffer = &msg[i]; } } @@ -631,16 +631,16 @@ SECURITY_STATUS SecureSocketImpl::decodeBufferFull(BYTE* pBuffer, DWORD bufSize, } else { - // everything decoded - if (securityStatus != SEC_E_OK && securityStatus != SEC_E_INCOMPLETE_MESSAGE && securityStatus != SEC_I_RENEGOTIATE && securityStatus != SEC_I_CONTEXT_EXPIRED) - { - throw SSLException("Failed to decode data", Utility::formatError(securityStatus)); - } - else if (securityStatus == SEC_E_OK) + if (securityStatus == SEC_E_OK) { + // everything decoded pBuffer = 0; bufSize = 0; } + else if (securityStatus != SEC_E_INCOMPLETE_MESSAGE && securityStatus != SEC_I_RENEGOTIATE && securityStatus != SEC_I_CONTEXT_EXPIRED) + { + return securityStatus; + } } if (securityStatus == SEC_I_RENEGOTIATE)