Ver código fonte

HPCC-12297 assert(hostname) error if SOAPCALL to invalid IP

Currently CSocket::pre_connect asserts that the hostname is valid. This
pull request changes the assertex to a JSocket exception with a meaningful

Signed-off-by: William Whitehead <william.whitehead@lexisnexis.com>
William Whitehead 10 anos atrás
pai
commit
30fa4e4ae4
2 arquivos alterados com 11 adições e 1 exclusões
  1. 3 0
      common/thorhelper/thorsoapcall.cpp
  2. 8 1
      system/jlib/jsocket.cpp

+ 3 - 0
common/thorhelper/thorsoapcall.cpp

@@ -210,6 +210,9 @@ public:
                 path.append("/");
             }
         }
+        IpAddress ipaddr(host);
+        if ( ipaddr.isNull())
+            throw MakeStringException(-1, "Invalid IP address %s", host.str());
     }
 };
 

+ 8 - 1
system/jlib/jsocket.cpp

@@ -791,7 +791,14 @@ size32_t CSocket::avail_read()
 
 int CSocket::pre_connect (bool block)
 {
-    assertex(hostname);
+    if (NULL == hostname || NULL == (*hostname))
+    {
+        StringBuffer err;
+        err.appendf("CSocket::pre_connect - Invalid/missing host IP address raised in : %s, line %d",__FILE__, __LINE__);
+        IJSOCK_Exception *e = new SocketException(JSOCKERR_bad_netaddr,err.str());
+        throw e;
+    }
+
     DEFINE_SOCKADDR(u);
     if (targetip.isNull()) {
         set_return_addr(hostport,hostname);