summaryrefslogtreecommitdiff
path: root/qpid/cpp/src/qpid/Url.cpp
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2008-11-20 23:11:50 +0000
committerAlan Conway <aconway@apache.org>2008-11-20 23:11:50 +0000
commit09d4f1d54e6365b7d4ccf83d9a4c19514ec11491 (patch)
treeb841f729bc39095df78feb3550fa0d5b5e2ae6c1 /qpid/cpp/src/qpid/Url.cpp
parentc4cbebed1e8d08771b75dde15e45e12f086baddc (diff)
downloadqpid-python-09d4f1d54e6365b7d4ccf83d9a4c19514ec11491.tar.gz
Add missing bounds checks.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@719419 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/qpid/Url.cpp')
-rw-r--r--qpid/cpp/src/qpid/Url.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/qpid/cpp/src/qpid/Url.cpp b/qpid/cpp/src/qpid/Url.cpp
index b7d6f76a94..f831167dd8 100644
--- a/qpid/cpp/src/qpid/Url.cpp
+++ b/qpid/cpp/src/qpid/Url.cpp
@@ -125,7 +125,7 @@ class UrlParser {
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 @@ class UrlParser {
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);