[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r11946: Fix bug 528: fix memory leak in base32_decode(). While there (in tor/trunk: . src/common src/or)
Author: nickm
Date: 2007-10-15 11:38:44 -0400 (Mon, 15 Oct 2007)
New Revision: 11946
Modified:
tor/trunk/
tor/trunk/ChangeLog
tor/trunk/src/common/crypto.c
tor/trunk/src/or/test.c
Log:
r15790@catbus: nickm | 2007-10-15 11:38:28 -0400
Fix bug 528: fix memory leak in base32_decode(). While there, also make base32_decode() accept upper-case inputs.
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r15790] on 8246c3cf-6607-4228-993b-4d95d33730f1
Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog 2007-10-15 15:36:30 UTC (rev 11945)
+++ tor/trunk/ChangeLog 2007-10-15 15:38:44 UTC (rev 11946)
@@ -18,6 +18,14 @@
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.
Modified: tor/trunk/src/common/crypto.c
===================================================================
--- tor/trunk/src/common/crypto.c 2007-10-15 15:36:30 UTC (rev 11945)
+++ tor/trunk/src/common/crypto.c 2007-10-15 15:38:44 UTC (rev 11946)
@@ -1891,8 +1891,10 @@
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;
}
}
Modified: tor/trunk/src/or/test.c
===================================================================
--- tor/trunk/src/or/test.c 2007-10-15 15:36:30 UTC (rev 11945)
+++ tor/trunk/src/or/test.c 2007-10-15 15:38:44 UTC (rev 11946)
@@ -3160,6 +3160,12 @@
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';