Skip to content

Commit 8b672f7

Browse files
committed
Merge pull request zaphoyd#524 from xavigibert/fix-uri
Fixed uri validator by checking its length.
2 parents 9dc013a + a4a79f6 commit 8b672f7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

websocketpp/uri.hpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,21 @@ class uri {
5454
int state = 0;
5555

5656
it = uri_string.begin();
57+
size_t uri_len = uri_string.length();
5758

58-
if (std::equal(it,it+6,"wss://")) {
59+
if (uri_len >= 7 && std::equal(it,it+6,"wss://")) {
5960
m_secure = true;
6061
m_scheme = "wss";
6162
it += 6;
62-
} else if (std::equal(it,it+5,"ws://")) {
63+
} else if (uri_len >= 6 && std::equal(it,it+5,"ws://")) {
6364
m_secure = false;
6465
m_scheme = "ws";
6566
it += 5;
66-
} else if (std::equal(it,it+7,"http://")) {
67+
} else if (uri_len >= 8 && std::equal(it,it+7,"http://")) {
6768
m_secure = false;
6869
m_scheme = "http";
6970
it += 7;
70-
} else if (std::equal(it,it+8,"https://")) {
71+
} else if (uri_len >= 9 && std::equal(it,it+8,"https://")) {
7172
m_secure = true;
7273
m_scheme = "https";
7374
it += 8;

0 commit comments

Comments
 (0)