This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch xerces-3.3
in repository https://gitbox.apache.org/repos/asf/xerces-c.git


The following commit(s) were added to refs/heads/xerces-3.3 by this push:
     new ea141eca0 XERCESC-2273 - Overflow parsing port in URI parser
ea141eca0 is described below

commit ea141eca0809cf920e2419ab242c8f4a1d8151e3
Author: Scott Cantor <[email protected]>
AuthorDate: Mon Nov 2 13:04:22 2026 -0500

    XERCESC-2273 - Overflow parsing port in URI parser
    
    https://issues.apache.org/jira/browse/XERCESC-2273
---
 src/xercesc/util/XMLUri.cpp | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/xercesc/util/XMLUri.cpp b/src/xercesc/util/XMLUri.cpp
index 4385b8109..f28447bdf 100644
--- a/src/xercesc/util/XMLUri.cpp
+++ b/src/xercesc/util/XMLUri.cpp
@@ -28,6 +28,8 @@
 #include <xercesc/util/XMLChar.hpp>
 #include <xercesc/util/OutOfMemoryException.hpp>
 
+#include <limits.h>
+
 XERCES_CPP_NAMESPACE_BEGIN
 
 // ---------------------------------------------------------------------------
@@ -2135,7 +2137,7 @@ bool XMLUri::isValidURI(const XMLUri* const baseURI
         }
     }
 
-    // we need to check if index has exceed the lenght or not
+    // we need to check if index has exceeded the length or not
     if (index < trimmedUriSpecLen)
     {
            if (!processPath(trimmedUriSpec + index, trimmedUriSpecLen - index, 
foundScheme, bAllowSpaces))
@@ -2443,8 +2445,14 @@ bool XMLUri::processAuthority( const XMLCh* const 
authSpec
                   userinfo = XMLUni::fgZeroLenString;
                   break;
                 }
-
-                port = (port * 10) + (int) (portStr[i] - chDigit_0);
+                if (port > INT_MAX / 10) {
+                    return false;
+                }
+                port *= 10;
+                if (port > INT_MAX - (int) (portStr[i] - chDigit_0)) {
+                    return false;
+                }
+                port += (int) (portStr[i] - chDigit_0);
             }
         }
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to