summaryrefslogtreecommitdiff
path: root/src/or/command.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-11-05 23:34:39 +0000
committerNick Mathewson <nickm@torproject.org>2007-11-05 23:34:39 +0000
commit6fcda5299fe7c0a40d3bff06ac4dcfe13d02d476 (patch)
treeeb42e117ce2b35dab8ae718df80c77946eae6040 /src/or/command.c
parent9a20a64b62b149b102a487b6dc099fa310553f3c (diff)
downloadtor-6fcda5299fe7c0a40d3bff06ac4dcfe13d02d476.tar.gz
tor-6fcda5299fe7c0a40d3bff06ac4dcfe13d02d476.zip
r14727@31-33-67: nickm | 2007-11-05 18:34:35 -0500
Make VERSIONS variable-length. svn:r12391
Diffstat (limited to 'src/or/command.c')
-rw-r--r--src/or/command.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/or/command.c b/src/or/command.c
index d46012ade5..100f1c379f 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -454,7 +454,6 @@ command_process_destroy_cell(cell_t *cell, or_connection_t *conn)
static void
command_process_versions_cell(var_cell_t *cell, or_connection_t *conn)
{
- uint16_t versionslen;
int highest_supported_version = 0;
const char *cp, *end;
if (conn->link_proto != 0 ||
@@ -466,13 +465,10 @@ command_process_versions_cell(var_cell_t *cell, or_connection_t *conn)
return;
}
tor_assert(conn->handshake_state);
- versionslen = ntohs(get_uint16(cell->payload));
- end = cell->payload + 2 + versionslen;
- if (end > cell->payload + CELL_PAYLOAD_SIZE)
- end = cell->payload + CELL_PAYLOAD_SIZE; /*XXXX020 warn?*/
- for (cp = cell->payload + 2; cp < end; ++cp) {
- uint8_t v = *cp;
- if (v == 1) {
+ end = cell->payload + cell->payload_len;
+ for (cp = cell->payload; cp+1 < end; ++cp) {
+ uint16_t v = ntohs(get_uint16(cp));
+ if (v == 1 || v == 2) {
if (v > highest_supported_version)
highest_supported_version = v;
}