[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/maint-0.3.1] If we successfully decompress an HTTP body, return immediately.
commit 5537e1fc45b683f10b3702f00e0b1280d4a5c87a
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Tue Jun 20 11:55:18 2017 -0400
If we successfully decompress an HTTP body, return immediately.
This prevents us from calling
allowed_anonymous_connection_compression_method() on the unused
guessed method (if any), and rejecting something that was already
safe to use.
---
changes/bug22670_03 | 6 ++++++
src/or/directory.c | 24 ++++++++++++++++++------
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/changes/bug22670_03 b/changes/bug22670_03
new file mode 100644
index 0000000..8a7aa49
--- /dev/null
+++ b/changes/bug22670_03
@@ -0,0 +1,6 @@
+ o Minor bugfixes (compression):
+ - When decompressing an object received over an anonymous directory
+ connection, if we have already successfully decompressed it using an
+ acceptable compression method, do not reject it for looking like an
+ unacceptable compression method. Fixes part of bug 22670; bugfix on
+ 0.3.1.1-alpha.
diff --git a/src/or/directory.c b/src/or/directory.c
index b6121d8..ac40e54 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -2255,9 +2255,15 @@ dir_client_decompress_response_body(char **bodyp, size_t *bodylenp,
goto done;
}
- if (tor_compress_supports_method(compression))
+ if (tor_compress_supports_method(compression)) {
tor_uncompress(&new_body, &new_len, body, body_len, compression,
!allow_partial, LOG_PROTOCOL_WARN);
+ if (new_body) {
+ /* We succeeded with the declared compression method. Great! */
+ rv = 0;
+ goto done;
+ }
+ }
/* Okay, if that didn't work, and we think that it was compressed
* differently, try that. */
@@ -2268,7 +2274,7 @@ dir_client_decompress_response_body(char **bodyp, size_t *bodylenp,
goto done;
}
- if (!new_body && tor_compress_supports_method(guessed) &&
+ if (tor_compress_supports_method(guessed) &&
compression != guessed) {
tor_uncompress(&new_body, &new_len, body, body_len, guessed,
!allow_partial, LOG_INFO);
@@ -2286,13 +2292,19 @@ dir_client_decompress_response_body(char **bodyp, size_t *bodylenp,
rv = -1;
goto done;
}
+
+ done:
if (new_body) {
- tor_free(*bodyp);
- *bodyp = new_body;
- *bodylenp = new_len;
+ if (rv == 0) {
+ /* success! */
+ tor_free(*bodyp);
+ *bodyp = new_body;
+ *bodylenp = new_len;
+ } else {
+ tor_free(new_body);
+ }
}
- done:
return rv;
}
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits