myserver-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myserver-commit] [SCM] GNU MyServer branch, master, updated. v0.9.2-390


From: Giuseppe Scrivano
Subject: [myserver-commit] [SCM] GNU MyServer branch, master, updated. v0.9.2-390-g37dacc4
Date: Wed, 15 Sep 2010 10:33:10 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU MyServer".

The branch, master has been updated
       via  37dacc479b8e07a31589010168906b0128793f1c (commit)
      from  f9eafc6c5ea79ad6804f16de5b0fcd37cefc6d1d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------


commit 37dacc479b8e07a31589010168906b0128793f1c
Author: Giuseppe Scrivano <address@hidden>
Date:   Wed Sep 15 12:30:36 2010 +0200

    Fix problem with HTTP Basic authentication header parsing.

diff --git a/myserver/src/protocol/http/http_headers.cpp 
b/myserver/src/protocol/http/http_headers.cpp
index 4b27bff..9d00073 100644
--- a/myserver/src/protocol/http/http_headers.cpp
+++ b/myserver/src/protocol/http/http_headers.cpp
@@ -725,8 +725,8 @@ int HttpHeaders::readReqAuthLine (HttpRequestHeader 
*request,
       const char *tmp = base64 + len - 1;
       const char* decodedPw;
       const char* decodedPwBuf;
-      char login[32];
-      char password[32];
+      char login[65];
+      char password[65];
       CBase64Utils base64Utils;
 
       if (len == -1)
@@ -734,26 +734,20 @@ int HttpHeaders::readReqAuthLine (HttpRequestHeader 
*request,
 
       login[0] = password[0] = '\0';
 
-      while (len > 0 && (*tmp == '\r' || *tmp == '\n'))
+      decodedPwBuf = decodedPw = base64Utils.decode (base64, &len);
+
+      for (i = 0; *decodedPw != ':'; i++)
         {
-          tmp--;
+          login[i] = *decodedPw++;
           len--;
         }
-      if (len <= 1)
-        return 400;
-
-      decodedPwBuf = decodedPw = base64Utils.decode (base64, &len);
-
-      for (i = 0; (*decodedPw != ':') && (i < 32);i++)
-        login[i] = *decodedPw++;
-
       login[i] = '\0';
 
       decodedPw++;
-      for (i = 0; (*decodedPw) && (i < 31); i++)
-        password[i] = *decodedPw++;
 
-      password[i] = '\0';
+      memcpy (password, decodedPw, len - 1);
+      password[len - 1] = '\0';
+
       connection->setLogin (login);
       connection->setPassword (password);
       delete [] decodedPwBuf;
diff --git a/myserver/tests/test_http_request.cpp 
b/myserver/tests/test_http_request.cpp
index bf17484..6ea606c 100644
--- a/myserver/tests/test_http_request.cpp
+++ b/myserver/tests/test_http_request.cpp
@@ -254,6 +254,9 @@ public:
                                                     &requestLength,
                                                     &header,
                                                     &connection);
+
+    CPPUNIT_ASSERT_EQUAL (strcmp ("user", connection.getLogin ()), 0);
+    CPPUNIT_ASSERT_EQUAL (strcmp ("freedom", connection.getPassword ()), 0);
     CPPUNIT_ASSERT (ret == 200);
   }
 

-----------------------------------------------------------------------

Summary of changes:
 myserver/src/protocol/http/http_headers.cpp |   24 +++++++++---------------
 myserver/tests/test_http_request.cpp        |    3 +++
 2 files changed, 12 insertions(+), 15 deletions(-)


hooks/post-receive
-- 
GNU MyServer



reply via email to

[Prev in Thread] Current Thread [Next in Thread]