diff options
author | emaste <emaste@FreeBSD.org> | 2015-02-09 01:44:09 +0000 |
---|---|---|
committer | emaste <emaste@FreeBSD.org> | 2015-02-09 01:44:09 +0000 |
commit | d61b076ede88b56f3372a55e7d1eac6a9d717120 (patch) | |
tree | a8f4b3abea3e6937e60728991c736e6e3d322fc1 /source/Utility/UriParser.cpp | |
parent | 0c2019f4ca6b2dc6d710f6bb16a0e3ed10271531 (diff) | |
download | FreeBSD-src-d61b076ede88b56f3372a55e7d1eac6a9d717120.zip FreeBSD-src-d61b076ede88b56f3372a55e7d1eac6a9d717120.tar.gz |
Import LLDB as of upstream SVN 228549 (git 39760838)
Diffstat (limited to 'source/Utility/UriParser.cpp')
-rw-r--r-- | source/Utility/UriParser.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/source/Utility/UriParser.cpp b/source/Utility/UriParser.cpp index bf1e601..1d4402f 100644 --- a/source/Utility/UriParser.cpp +++ b/source/Utility/UriParser.cpp @@ -15,6 +15,9 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Host/StringConvert.h" + +using namespace lldb_private; //---------------------------------------------------------------------- // UriParser::Parse @@ -33,17 +36,21 @@ UriParser::Parse(const char* uri, char path_buf[2049] = {'/', 0}; bool ok = false; - if (4==sscanf(uri, "%99[^:/]://%255[^/:]:%[^/]/%2047s", scheme_buf, hostname_buf, port_buf, path_buf+1)) { ok = true; } - else if (3==sscanf(uri, "%99[^:/]://%255[^/:]:%[^/]", scheme_buf, hostname_buf, port_buf)) { ok = true; } + if (4==sscanf(uri, "%99[^:/]://%255[^/:]:%10[^/]/%2047s", scheme_buf, hostname_buf, port_buf, path_buf+1)) { ok = true; } + else if (3==sscanf(uri, "%99[^:/]://%255[^/:]:%10[^/]", scheme_buf, hostname_buf, port_buf)) { ok = true; } else if (3==sscanf(uri, "%99[^:/]://%255[^/]/%2047s", scheme_buf, hostname_buf, path_buf+1)) { ok = true; } else if (2==sscanf(uri, "%99[^:/]://%255[^/]", scheme_buf, hostname_buf)) { ok = true; } - char* end = port_buf; - int port_tmp = strtoul(port_buf, &end, 10); - if (*end != 0) + bool success = false; + int port_tmp = -1; + if (port_buf[0]) { - // there are invalid characters in port_buf - return false; + port_tmp = StringConvert::ToUInt32(port_buf, UINT32_MAX, 10, &success); + if (!success || port_tmp > 65535) + { + // there are invalid characters in port_buf + return false; + } } if (ok) |