aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorteor <teor@torproject.org>2018-09-05 21:07:58 +1000
committerteor <teor@torproject.org>2018-09-07 12:40:11 +1000
commit9d5c6317b51530d606222cc2b7f6f5f5d7defe24 (patch)
tree4be3eef1af2bae486cbac79e40a3eb2683908391 /src
parentff1486385aed1172c18a8a593dec2684de891f60 (diff)
downloadtor-9d5c6317b51530d606222cc2b7f6f5f5d7defe24.tar.gz
tor-9d5c6317b51530d606222cc2b7f6f5f5d7defe24.zip
hs: Silence a spurious warning in rend_client_send_introduction()
gcc 8 warns that extend_info_t.nickname might be truncated by strncpy(). But it doesn't know that nickname can either contain a hex id, or a nicknames. hex ids are only used for general and HSDir circuits. Fixes bug 27463; bugfix on 0.1.1.2-alpha.
Diffstat (limited to 'src')
-rw-r--r--src/or/rendclient.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/or/rendclient.c b/src/or/rendclient.c
index a93bc94a9c..f0144b076f 100644
--- a/src/or/rendclient.c
+++ b/src/or/rendclient.c
@@ -269,6 +269,15 @@ rend_client_send_introduction(origin_circuit_t *introcirc,
dh_offset = v3_shift+7+DIGEST_LEN+2+klen+REND_COOKIE_LEN;
} else {
/* Version 0. */
+
+ /* Some compilers are smart enough to work out that nickname can be more
+ * than 19 characters, when it's a hexdigest. They warn that strncpy()
+ * will truncate hexdigests without NUL-terminating them. But we only put
+ * hexdigests in HSDir and general circuit exits. */
+ if (BUG(strlen(rendcirc->build_state->chosen_exit->nickname)
+ > MAX_NICKNAME_LEN)) {
+ goto perm_err;
+ }
strncpy(tmp, rendcirc->build_state->chosen_exit->nickname,
(MAX_NICKNAME_LEN+1)); /* nul pads */
memcpy(tmp+MAX_NICKNAME_LEN+1, rendcirc->rend_data->rend_cookie,