summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom MacWright <tom@macwright.org>2015-10-26 13:51:53 -0400
committerTom MacWright <tom@macwright.org>2015-10-28 10:44:33 -0400
commitc80c823da25bcc67d89158f339be7cfb93c45f50 (patch)
tree6977d8c5d732f2b6fce24f52883ffa6617fbc7cc /src
parent6bb709ef422b1b0945d1fe7bcc0daba0498e7f49 (diff)
downloadqtlocation-mapboxgl-c80c823da25bcc67d89158f339be7cfb93c45f50.tar.gz
[core] Ensure URL normalization is safe. Fixes #2695
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/util/mapbox.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mbgl/util/mapbox.cpp b/src/mbgl/util/mapbox.cpp
index 9a97f281d9..0798607467 100644
--- a/src/mbgl/util/mapbox.cpp
+++ b/src/mbgl/util/mapbox.cpp
@@ -1,4 +1,5 @@
#include <mbgl/util/mapbox.hpp>
+#include <mbgl/platform/log.hpp>
#include <stdexcept>
#include <vector>
@@ -50,6 +51,12 @@ std::string normalizeStyleURL(const std::string& url, const std::string& accessT
}
std::vector<std::string> pathname = getMapboxURLPathname(url);
+
+ if (pathname.size() < 3) {
+ Log::Error(Event::ParseStyle, "Invalid style URL");
+ return url;
+ }
+
std::string user = pathname[1];
std::string id = pathname[2];
bool isDraft = pathname.size() > 3;
@@ -62,6 +69,12 @@ std::string normalizeSpriteURL(const std::string& url, const std::string& access
}
std::vector<std::string> pathname = getMapboxURLPathname(url);
+
+ if (pathname.size() < 3) {
+ Log::Error(Event::ParseStyle, "Invalid sprite URL");
+ return url;
+ }
+
std::string user = pathname[1];
bool isDraft = pathname.size() > 3;
@@ -85,6 +98,12 @@ std::string normalizeGlyphsURL(const std::string& url, const std::string& access
}
std::vector<std::string> pathname = getMapboxURLPathname(url);
+
+ if (pathname.size() < 4) {
+ Log::Error(Event::ParseStyle, "Invalid glyph URL");
+ return url;
+ }
+
std::string user = pathname[1];
std::string fontstack = pathname[2];
std::string range = pathname[3];