diff options
| author | Alan Conway <aconway@apache.org> | 2008-11-20 23:11:50 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2008-11-20 23:11:50 +0000 |
| commit | 3bfd565f5f26056ff5691fc2e9f6259a5a5ca993 (patch) | |
| tree | f973f365f495a0dc6e3589e3d040edf23e641e2a /cpp | |
| parent | cd7122f933b91cbefee7b813915bfa9fd3103384 (diff) | |
| download | qpid-python-3bfd565f5f26056ff5691fc2e9f6259a5a5ca993.tar.gz | |
Add missing bounds checks.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@719419 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
| -rw-r--r-- | cpp/src/qpid/Url.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/cpp/src/qpid/Url.cpp b/cpp/src/qpid/Url.cpp index b7d6f76a94..f831167dd8 100644 --- a/cpp/src/qpid/Url.cpp +++ b/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); |
