Author: aconway
Date: Thu Nov 20 15:11:50 2008
New Revision: 719419

URL: http://svn.apache.org/viewvc?rev=719419&view=rev
Log:
Add missing bounds checks.

Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/Url.cpp

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/Url.cpp
URL: 
http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/Url.cpp?rev=719419&r1=719418&r2=719419&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/Url.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/Url.cpp Thu Nov 20 15:11:50 2008
@@ -125,7 +125,7 @@
 
     bool pctEncoded() { return literal("%") && hexDigit() && hexDigit(); }
 
-    bool hexDigit() { return ::strchr("01234567890abcdefABCDEF", *i) && 
advance(); }
+    bool hexDigit() { return i < end && ::strchr("01234567890abcdefABCDEF", 
*i) && advance(); }
     
     bool port(uint16_t& p) { return decimalInt(p); }
 
@@ -133,13 +133,16 @@
     
     template <class IntType> bool decimalInt(IntType& n) {
         const char* start = i;
-        while (::isdigit(*i)) ++i;
+        while (decDigit())
+            ;
         try {
             n = lexical_cast<IntType>(string(start, i)); 
             return true;
         } catch(...) { return false; }
     }
 
+    bool decDigit() { return i < end && ::isdigit(*i) && advance(); }
+
     bool literal(const char* s) {
         int n = ::strlen(s);
         if (n <= end-i && equal(s, s+n, i)) return advance(n);


Reply via email to