summaryrefslogtreecommitdiff
path: root/source/Utility
diff options
context:
space:
mode:
Diffstat (limited to 'source/Utility')
-rw-r--r--source/Utility/StringExtractorGDBRemote.cpp3
-rw-r--r--source/Utility/StringExtractorGDBRemote.h1
-rw-r--r--source/Utility/UriParser.cpp21
-rw-r--r--source/Utility/UriParser.h8
4 files changed, 26 insertions, 7 deletions
diff --git a/source/Utility/StringExtractorGDBRemote.cpp b/source/Utility/StringExtractorGDBRemote.cpp
index 161ac6a026f24..a137d365984f1 100644
--- a/source/Utility/StringExtractorGDBRemote.cpp
+++ b/source/Utility/StringExtractorGDBRemote.cpp
@@ -265,6 +265,9 @@ StringExtractorGDBRemote::GetServerPacketType () const
case 'H':
return eServerPacketType_H;
+ case 'I':
+ return eServerPacketType_I;
+
case 'k':
if (packet_size == 1) return eServerPacketType_k;
break;
diff --git a/source/Utility/StringExtractorGDBRemote.h b/source/Utility/StringExtractorGDBRemote.h
index e16403c2d154e..b51be7d7c28a8 100644
--- a/source/Utility/StringExtractorGDBRemote.h
+++ b/source/Utility/StringExtractorGDBRemote.h
@@ -130,6 +130,7 @@ public:
eServerPacketType_g,
eServerPacketType_G,
eServerPacketType_H,
+ eServerPacketType_I, // stdin notification
eServerPacketType_k,
eServerPacketType_m,
eServerPacketType_M,
diff --git a/source/Utility/UriParser.cpp b/source/Utility/UriParser.cpp
index bf1e601485b43..1d4402feec6e8 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)
diff --git a/source/Utility/UriParser.h b/source/Utility/UriParser.h
index c46628d3bd68f..fb129eaf79d5b 100644
--- a/source/Utility/UriParser.h
+++ b/source/Utility/UriParser.h
@@ -20,6 +20,14 @@
class UriParser
{
public:
+ // Parses
+ // RETURN VALUE
+ // if url is valid, function returns true and
+ // scheme/hostname/port/path are set to the parsed values
+ // port it set to -1 if it is not included in the URL
+ //
+ // if the url is invalid, function returns false and
+ // output parameters remain unchanged
static bool Parse(const char* uri,
std::string& scheme,
std::string& hostname,