changeset 1213:787059de6b9a

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 04 Nov 2014 14:39:13 +0100
parents 79f868a7f972
children 973328a7a709 f38b09e9afed
files Core/HttpServer/MongooseServer.cpp
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Core/HttpServer/MongooseServer.cpp	Tue Nov 04 13:58:26 2014 +0100
+++ b/Core/HttpServer/MongooseServer.cpp	Tue Nov 04 14:39:13 2014 +0100
@@ -418,7 +418,8 @@
     if (auth != headers.end())
     {
       std::string s = auth->second;
-      if (s.substr(0, 6) == "Basic ")
+      if (s.size() > 6 &&
+          s.substr(0, 6) == "Basic ")
       {
         std::string b64 = s.substr(6);
         granted = that.IsValidBasicHttpAuthentication(b64);
@@ -439,7 +440,8 @@
     }
 
     std::string s = auth->second;
-    if (s.substr(0, 6) != "Basic ")
+    if (s.size() <= 6 ||
+        s.substr(0, 6) != "Basic ")
     {
       return "";
     }