Explorar o código

HPCC-19959 Port need to be validated when adding ESDL binding

- Add sanity check on the port value

Signed-off-by: mayx <yanrui.ma@lexisnexisrisk.com>
mayx %!s(int64=7) %!d(string=hai) anos
pai
achega
bffc5c3d2b

+ 19 - 0
esp/services/esdl_svc_engine/esdl_store.cpp

@@ -456,6 +456,25 @@ public:
             return -1;
         }
 
+        if(espPort && *espPort)
+        {
+            while(*espPort == '0')
+                espPort++;
+
+            int ind = 0;
+            for ( ; espPort[ind]; ind++)
+            {
+                if (!isdigit(espPort[ind]))
+                    throw MakeStringException(-1, "Esp port can only be a positive integer.");
+            }
+            if(ind > 5)
+                throw MakeStringException(-1, "Esp port should be between 1 and 65535");
+
+            int port = atoi(espPort);
+            if(port <= 0 || port > 65535)
+                throw MakeStringException(-1, "Esp port should be between 1 and 65535");
+        }
+
         if (!definitionId || !*definitionId)
         {
             message.set("Could not configure DESDL service: Target Esdl definition id not available");

+ 1 - 1
esp/services/ws_esdlconfig/ws_esdlconfigservice.cpp

@@ -499,7 +499,7 @@ bool CWsESDLConfigEx::onPublishESDLBinding(IEspContext &context, IEspPublishESDL
             resp.updateStatus().setCode(m_esdlStore->bindService(espBindingName.str(),
                                                            methodstree.get(),
                                                            espProcName.str(),
-                                                           espPort,
+                                                           espPort.str(),
                                                            esdlDefIdSTR.str(),
                                                            esdlServiceName.str(),
                                                            msg,