Selaa lähdekoodia

HPCC-20553 New defects reported by Coverity Scan for HPCC-Platform on 17th of September

CSecureSmartSocketFactory::connect_timeout is calling secure_connect without
checking the return code.  This PR adds a check, and throws an error if
it returns a negative value

Signed-off-by: Russ Whitehead <william.whitehead@lexisnexis.com>
Russ Whitehead 6 vuotta sitten
vanhempi
commit
c804251f16

+ 3 - 1
system/security/securesocket/securesocket.cpp

@@ -1715,7 +1715,9 @@ public:
         {
             ssock.setown(secureContext->createSecureSocket(sock.getClear()));
             // secure_connect may also DBGLOG() errors ...
-            ssock->secure_connect();
+            int res = ssock->secure_connect();
+            if (res < 0)
+                throw MakeStringException(-1, "connect_timeout : Failed to establish secure connection");
         }
         catch (IException *)
         {

+ 6 - 2
tools/testsocket/testsocket.cpp

@@ -553,7 +553,9 @@ int doSendQuery(const char * ip, unsigned port, const char * base)
                     if (!persistSecureContext)
                         persistSecureContext.setown(createSecureSocketContext(ClientSocket));
                     persistSSock.setown(persistSecureContext->createSecureSocket(persistSocket.getClear()));
-                    persistSSock->secure_connect();
+                    int res = persistSSock->secure_connect();
+                    if (res < 0)
+                        throw MakeStringException(-1, "doSendQuery : Failed to establish secure connection");
                     persistSocket.setown(persistSSock.getClear());
 #else
                     throw MakeStringException(-1, "OpenSSL disabled in build");
@@ -571,7 +573,9 @@ int doSendQuery(const char * ip, unsigned port, const char * base)
 #ifdef _USE_OPENSSL
                 secureContext.setown(createSecureSocketContext(ClientSocket));
                 Owned<ISecureSocket> ssock = secureContext->createSecureSocket(socket.getClear());
-                ssock->secure_connect();
+                int res = ssock->secure_connect();
+                if (res < 0)
+                    throw MakeStringException(-1, "doSendQuery : Failed to establish secure connection");
                 socket.setown(ssock.getClear());
 #else
                 throw MakeStringException(1, "OpenSSL disabled in build");