]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
r15790@catbus: nickm | 2007-10-15 11:38:28 -0400
authorNick Mathewson <nickm@torproject.org>
Mon, 15 Oct 2007 15:38:44 +0000 (15:38 +0000)
committerNick Mathewson <nickm@torproject.org>
Mon, 15 Oct 2007 15:38:44 +0000 (15:38 +0000)
 Fix bug 528: fix memory leak in base32_decode().  While there, also make base32_decode() accept upper-case inputs.

svn:r11946

ChangeLog
src/common/crypto.c
src/or/test.c

index c3eb64a1009ec55f610595ab49dc9242699f9926..9873a50c4a9f1956a19f725cdd39161fa7c642be 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -18,6 +18,14 @@ Changes in version 0.2.0.9-alpha - 2007-10-??
       after publishing the consensus; avoid a heisenbug that made them stick
       around indefinitely.
 
+  o Minor bugfixes (memory leaks):
+    - Stop leaking memory on failing case of base32_decode.  Bugfix on
+      0.2.0.7-alpha.
+
+  o Minor bugfixes (misc):
+    - Make base32_decode() accept upper-case letters.  Bugfix on
+      0.2.0.7-alpha.
+
   o Code simplifications and refactoring:
     - Remove support for the old bw_accounting file: we've been storing
       bandwidth accounting information in the state file since 0.1.2.5-alpha.
index 2de0f3169514789fbd49246dfed01cbe9194fd49..b21529823863ca458204fda82d93d2b23dfe8d21 100644 (file)
@@ -1891,8 +1891,10 @@ base32_decode(char *dest, size_t destlen, const char *src, size_t srclen)
   for (j = 0; j < srclen; ++j) {
     if (src[j] > 0x60 && src[j] < 0x7B) tmp[j] = src[j] - 0x61;
     else if (src[j] > 0x31 && src[j] < 0x38) tmp[j] = src[j] - 0x18;
+    else if (src[j] > 0x40 && src[j] < 0x5B) tmp[j] = src[j] - 0x41;
     else {
       log_warn(LD_BUG, "illegal character in base32 encoded string");
+      tor_free(tmp);
       return -1;
     }
   }
index 9c707099b2d37407b8608d70961854974d226411..b890959a868355f3a4af7ac2095c47e91ff4b09a 100644 (file)
@@ -3160,6 +3160,12 @@ test_crypto_base32_decode(void)
   res = base32_decode(decoded, 60, encoded, 96);
   test_eq(res, 0);
   test_memeq(plain, decoded, 60);
+  /* Encode, uppercase, and decode a random string. */
+  base32_encode(encoded, 96 + 1, plain, 60);
+  tor_strupper(encoded);
+  res = base32_decode(decoded, 60, encoded, 96);
+  test_eq(res, 0);
+  test_memeq(plain, decoded, 60);
   /* Change encoded string and decode. */
   if (encoded[0] == 'a')
     encoded[0] = 'b';