diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-04-27 10:59:48 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-04-27 10:59:48 -0400 |
commit | 49deb1e1b810e348bfa9fb27a0f0ef54f3694cc9 (patch) | |
tree | 73aafa22564f22b5f681dac8e3ef302a0f3e422f /src/common/compress.c | |
parent | 199e61feb560e2368d1eec475dd828118754cf71 (diff) | |
download | tor-49deb1e1b810e348bfa9fb27a0f0ef54f3694cc9.tar.gz tor-49deb1e1b810e348bfa9fb27a0f0ef54f3694cc9.zip |
Document and test nul-terminating behavior of tor_uncompress()
We added this as a safety feature, but there are a few places in the
code that actually depend on it.
Diffstat (limited to 'src/common/compress.c')
-rw-r--r-- | src/common/compress.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/common/compress.c b/src/common/compress.c index 771f5ab7b6..9a24025db0 100644 --- a/src/common/compress.c +++ b/src/common/compress.c @@ -221,6 +221,12 @@ tor_compress(char **out, size_t *out_len, * *<b>out</b>, and its length in *<b>out_len</b>. Return 0 on success, -1 on * failure. * + * If any bytes are written to <b>out</b>, an extra byte NUL is always + * written at the end, but not counted in <b>out_len</b>. This is a + * safety feature to ensure that the output can be treated as a + * NUL-terminated string -- though of course, callers should check + * out_len anyway. + * * If <b>complete_only</b> is true, we consider a truncated input as a * failure; otherwise we decompress as much as we can. Warn about truncated * or corrupt inputs at <b>protocol_warn_level</b>. |