aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-12-18 20:13:58 -0500
committerNick Mathewson <nickm@torproject.org>2016-12-18 20:17:24 -0500
commitd978216dea6b21ac38230a59d172139185a68dbd (patch)
tree07f527c928e9afabc31aed646816e9462e704d0e /src
parent9db47e792160766de49b76bff71afdc4f743df88 (diff)
downloadtor-d978216dea6b21ac38230a59d172139185a68dbd.tar.gz
tor-d978216dea6b21ac38230a59d172139185a68dbd.zip
Fix parsing bug with unecognized token at EOS
In get_token(), we could read one byte past the end of the region. This is only a big problem in the case where the region itself is (a) potentially hostile, and (b) not explicitly nul-terminated. This patch fixes the underlying bug, and also makes sure that the one remaining case of not-NUL-terminated potentially hostile data gets NUL-terminated. Fix for bug 21018, TROVE-2016-12-002, and CVE-2016-1254
Diffstat (limited to 'src')
-rw-r--r--src/or/routerparse.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 176c16f904..71373ce63e 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -3857,7 +3857,7 @@ get_next_token(memarea_t *area,
if (tok->tp == ERR_) {
/* No keyword matched; call it an "K_opt" or "A_unrecognized" */
- if (**s == '@')
+ if (*s < eol && **s == '@')
tok->tp = A_UNKNOWN_;
else
tok->tp = K_OPT;
@@ -4863,7 +4863,7 @@ rend_decrypt_introduction_points(char **ipos_decrypted,
crypto_cipher_free(cipher);
len = ipos_encrypted_size - 2 - client_entries_len - CIPHER_IV_LEN;
- dec = tor_malloc(len);
+ dec = tor_malloc_zero(len + 1);
declen = crypto_cipher_decrypt_with_iv(session_key, dec, len,
ipos_encrypted + 2 + client_entries_len,
ipos_encrypted_size - 2 - client_entries_len);
@@ -4895,7 +4895,7 @@ rend_decrypt_introduction_points(char **ipos_decrypted,
"small.");
return -1;
}
- dec = tor_malloc_zero(ipos_encrypted_size - CIPHER_IV_LEN - 1);
+ dec = tor_malloc_zero(ipos_encrypted_size - CIPHER_IV_LEN - 1 + 1);
declen = crypto_cipher_decrypt_with_iv(descriptor_cookie, dec,
ipos_encrypted_size -