]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix bug2752 : 48-char HTTPProxyAuthenticator limitation
authorMichael Yakubovich <e_zine99@yahoo.com>
Mon, 16 May 2011 20:09:35 +0000 (16:09 -0400)
committerMichael Yakubovich <e_zine99@yahoo.com>
Mon, 16 May 2011 20:09:35 +0000 (16:09 -0400)
Bumped the char maximum to 512 for HTTPProxyAuthenticator &
HTTPSProxyAuthenticator. Now stripping all '\n' after base64
encoding in alloc_http_authenticator.

changes/bug2752 [new file with mode: 0644]
src/or/config.c
src/or/connection.c

diff --git a/changes/bug2752 b/changes/bug2752
new file mode 100644 (file)
index 0000000..328f11e
--- /dev/null
@@ -0,0 +1,5 @@
+  o Minor bugfixes
+    - Tor used to limit HttpProxyAuthenticator values to 48 characters.
+    Changed the limit to 512 characters by removing base64 newlines.
+    Fixes bug 2917.
+
index 614fc48c3e5181b5fec6f2b5f87040f42452eb71..36a8940cab13b9aafee302fef2d2ae2ac1362311 100644 (file)
@@ -3398,8 +3398,8 @@ options_validate(or_options_t *old_options, or_options_t *options,
   }
 
   if (options->HTTPProxyAuthenticator) {
-    if (strlen(options->HTTPProxyAuthenticator) >= 48)
-      REJECT("HTTPProxyAuthenticator is too long (>= 48 chars).");
+    if (strlen(options->HTTPProxyAuthenticator) >= 512)
+      REJECT("HTTPProxyAuthenticator is too long (>= 512 chars).");
   }
 
   if (options->HTTPSProxy) { /* parse it now */
@@ -3412,8 +3412,8 @@ options_validate(or_options_t *old_options, or_options_t *options,
   }
 
   if (options->HTTPSProxyAuthenticator) {
-    if (strlen(options->HTTPSProxyAuthenticator) >= 48)
-      REJECT("HTTPSProxyAuthenticator is too long (>= 48 chars).");
+    if (strlen(options->HTTPSProxyAuthenticator) >= 512)
+      REJECT("HTTPSProxyAuthenticator is too long (>= 512 chars).");
   }
 
   if (options->Socks4Proxy) { /* parse it now */
index 5054909df931813aa2842e80d3d68e5c0c65c1f8..bcdde67568020ec21a6f55e915fe8b8695056d52 100644 (file)
@@ -3232,8 +3232,17 @@ alloc_http_authenticator(const char *authenticator)
                     authenticator, authenticator_length) < 0) {
     tor_free(base64_authenticator); /* free and set to null */
   } else {
-    /* remove extra \n at end of encoding */
-    base64_authenticator[strlen(base64_authenticator) - 1] = 0;
+    int i = 0, j = 0;
+    int len = strlen(base64_authenticator);
+
+    /* remove all newline occurrences within the string */
+    for (i=0; i < len; ++i) {
+      if ('\n' != base64_authenticator[i]) {
+        base64_authenticator[j] = base64_authenticator[i];
+        ++j;
+      }
+    }
+    base64_authenticator[j]='\0';
   }
   return base64_authenticator;
 }