summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--changes/bug160824
-rw-r--r--changes/bug226725
-rw-r--r--changes/new_requirement_pkgconfig5
-rw-r--r--doc/tor.1.txt6
-rw-r--r--src/common/compress.c44
-rw-r--r--src/common/compress_none.c2
6 files changed, 46 insertions, 20 deletions
diff --git a/changes/bug16082 b/changes/bug16082
new file mode 100644
index 0000000000..0f2f04fb35
--- /dev/null
+++ b/changes/bug16082
@@ -0,0 +1,4 @@
+ o Documentation:
+ - Correctly note that bandwidth accounting values are stored in the
+ state file, and the bw_accounting file is now obsolete. Closes
+ ticket 16082.
diff --git a/changes/bug22672 b/changes/bug22672
new file mode 100644
index 0000000000..ec6681149d
--- /dev/null
+++ b/changes/bug22672
@@ -0,0 +1,5 @@
+ o Minor features (compression, defensive programming):
+ - Detect and break out of infinite loops in our compression code.
+ We don't think that any such loops exist now, but it's best to be
+ safe. Closes ticket 22672.
+
diff --git a/changes/new_requirement_pkgconfig b/changes/new_requirement_pkgconfig
new file mode 100644
index 0000000000..503ff58c9e
--- /dev/null
+++ b/changes/new_requirement_pkgconfig
@@ -0,0 +1,5 @@
+ o New dependencies:
+ - To build with zstd and lzma support, Tor now requires the
+ pkg-config tool at build time. (This requirement was new in
+ 0.3.1.1-alpha, but was not noted at the time. Noting it here to
+ close ticket 22623.)
diff --git a/doc/tor.1.txt b/doc/tor.1.txt
index ff9fba726b..2459969f98 100644
--- a/doc/tor.1.txt
+++ b/doc/tor.1.txt
@@ -2725,8 +2725,7 @@ __DataDirectory__**/state**::
A set of persistent key-value mappings. These are documented in
the file. These include:
- The current entry guards and their status.
- - The current bandwidth accounting values (unused so far; see
- below).
+ - The current bandwidth accounting values.
- When the file was last written
- What version of Tor generated the state file
- A short history of bandwidth usage, as produced in the server
@@ -2746,8 +2745,7 @@ __DataDirectory__**/diff-cache**::
__DataDirectory__**/bw_accounting**::
Used to track bandwidth accounting values (when the current period starts
and ends; how much has been read and written so far this period). This file
- is obsolete, and the data is now stored in the \'state' file as well. Only
- used when bandwidth accounting is enabled.
+ is obsolete, and the data is now stored in the \'state' file instead.
__DataDirectory__**/control_auth_cookie**::
Used for cookie authentication with the controller. Location can be
diff --git a/src/common/compress.c b/src/common/compress.c
index c6c3897989..7926faaa60 100644
--- a/src/common/compress.c
+++ b/src/common/compress.c
@@ -105,8 +105,8 @@ tor_compress_impl(int compress,
if (stream == NULL) {
log_warn(LD_GENERAL, "NULL stream while %scompressing",
compress?"":"de");
- log_debug(LD_GENERAL, "method: %d level: %d at len: %zd",
- method, compression_level, in_len);
+ log_debug(LD_GENERAL, "method: %d level: %d at len: %lu",
+ method, compression_level, (unsigned long)in_len);
return -1;
}
@@ -146,8 +146,8 @@ tor_compress_impl(int compress,
"Unexpected %s while %scompressing",
complete_only?"end of input":"result",
compress?"":"de");
- log_debug(LD_GENERAL, "method: %d level: %d at len: %zd",
- method, compression_level, in_len);
+ log_debug(LD_GENERAL, "method: %d level: %d at len: %lu",
+ method, compression_level, (unsigned long)in_len);
goto err;
} else {
if (in_len == 0) {
@@ -542,28 +542,42 @@ tor_compress_process(tor_compress_state_t *state,
int finish)
{
tor_assert(state != NULL);
+ const size_t in_len_orig = *in_len;
+ const size_t out_len_orig = *out_len;
+ tor_compress_output_t rv;
switch (state->method) {
case GZIP_METHOD:
case ZLIB_METHOD:
- return tor_zlib_compress_process(state->u.zlib_state,
- out, out_len, in, in_len,
- finish);
+ rv = tor_zlib_compress_process(state->u.zlib_state,
+ out, out_len, in, in_len,
+ finish);
+ break;
case LZMA_METHOD:
- return tor_lzma_compress_process(state->u.lzma_state,
- out, out_len, in, in_len,
- finish);
+ rv =tor_lzma_compress_process(state->u.lzma_state,
+ out, out_len, in, in_len,
+ finish);
+ break;
case ZSTD_METHOD:
- return tor_zstd_compress_process(state->u.zstd_state,
- out, out_len, in, in_len,
- finish);
+ rv = tor_zstd_compress_process(state->u.zstd_state,
+ out, out_len, in, in_len,
+ finish);
+ break;
case NO_METHOD:
- return tor_cnone_compress_process(out, out_len, in, in_len,
- finish);
+ rv = tor_cnone_compress_process(out, out_len, in, in_len,
+ finish);
+ break;
+ default:
case UNKNOWN_METHOD:
goto err;
}
+ if (BUG((rv == TOR_COMPRESS_OK) &&
+ *in_len == in_len_orig &&
+ *out_len == out_len_orig)) {
+ return TOR_COMPRESS_ERROR;
+ }
+ return rv;
err:
return TOR_COMPRESS_ERROR;
}
diff --git a/src/common/compress_none.c b/src/common/compress_none.c
index b76e6010ec..34314e4af7 100644
--- a/src/common/compress_none.c
+++ b/src/common/compress_none.c
@@ -4,7 +4,7 @@
/* See LICENSE for licensing information */
/**
- * \file compress_lzma.c
+ * \file compress_none.c
* \brief Compression backend for identity compression.
*
* We actually define this backend so that we can treat the identity transform