[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r13609: We were comparing the raw BridgePassword entry with a base64 (in tor/trunk: . src/or)
Author: arma
Date: 2008-02-19 21:05:28 -0500 (Tue, 19 Feb 2008)
New Revision: 13609
Modified:
tor/trunk/ChangeLog
tor/trunk/src/or/directory.c
Log:
We were comparing the raw BridgePassword entry with a base64'ed
version of it, when handling a "/tor/networkstatus-bridges"
directory request. Now compare correctly. Noticed by Veracode.
Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog 2008-02-20 01:01:09 UTC (rev 13608)
+++ tor/trunk/ChangeLog 2008-02-20 02:05:28 UTC (rev 13609)
@@ -48,6 +48,9 @@
- Make the new hidden service code respect the SafeLogging setting.
Bugfix on 0.2.0.x. Patch from Karsten.
- Detect size overflow in zlib code.
+ - We were comparing the raw BridgePassword entry with a base64'ed
+ version of it, when handling a "/tor/networkstatus-bridges"
+ directory request. Now compare correctly. Noticed by Veracode.
o Code simplifications and refactoring:
- Remove the tor_strpartition function: its logic was confused,
Modified: tor/trunk/src/or/directory.c
===================================================================
--- tor/trunk/src/or/directory.c 2008-02-20 01:01:09 UTC (rev 13608)
+++ tor/trunk/src/or/directory.c 2008-02-20 02:05:28 UTC (rev 13609)
@@ -2639,27 +2639,19 @@
connection_dir_is_encrypted(conn) &&
!strcmp(url,"/tor/networkstatus-bridges")) {
char *status;
- char decoded[64];
- char *secret;
- int r;
+ char *secret = alloc_http_authenticator(options->BridgePassword);
header = http_get_header(headers, "Authorization: Basic ");
- if (!header) {
+ /* now make sure the password is there and right */
+ if (!header || strcmp(header, secret)) {
write_http_status_line(conn, 404, "Not found");
- goto done;
- }
-
- /* now make sure the password is right */
- r = base64_decode(decoded, sizeof(decoded), header, strlen(header));
- secret = alloc_http_authenticator(options->BridgePassword);
- if (r < 0 || (unsigned)r != strlen(secret) || memcmp(decoded, secret, r)) {
- /* failed to decode, or didn't match. Refuse. */
- write_http_status_line(conn, 404, "Not found");
+ tor_free(secret);
tor_free(header);
goto done;
}
tor_free(secret);
+ tor_free(header);
/* all happy now. send an answer. */
status = networkstatus_getinfo_by_purpose("bridge", time(NULL));