From a4a79f6bf6b445d7981ca4738cce2705c9b26724 Mon Sep 17 00:00:00 2001 From: Xavier Gibert Serra Date: Thu, 18 Feb 2016 08:27:18 -0800 Subject: [PATCH] Fixed uri validator. This bug caused asan error heap-buffer-overflow when passing a short address. --- websocketpp/uri.hpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/websocketpp/uri.hpp b/websocketpp/uri.hpp index 44a79cf31..7159234f0 100644 --- a/websocketpp/uri.hpp +++ b/websocketpp/uri.hpp @@ -54,20 +54,21 @@ class uri { int state = 0; it = uri_string.begin(); + size_t uri_len = uri_string.length(); - if (std::equal(it,it+6,"wss://")) { + if (uri_len >= 7 && std::equal(it,it+6,"wss://")) { m_secure = true; m_scheme = "wss"; it += 6; - } else if (std::equal(it,it+5,"ws://")) { + } else if (uri_len >= 6 && std::equal(it,it+5,"ws://")) { m_secure = false; m_scheme = "ws"; it += 5; - } else if (std::equal(it,it+7,"http://")) { + } else if (uri_len >= 8 && std::equal(it,it+7,"http://")) { m_secure = false; m_scheme = "http"; it += 7; - } else if (std::equal(it,it+8,"https://")) { + } else if (uri_len >= 9 && std::equal(it,it+8,"https://")) { m_secure = true; m_scheme = "https"; it += 8;