r14727@31-33-67: nickm | 2007-11-05 18:34:35 -0500

Make VERSIONS variable-length.


svn:r12391
This commit is contained in:
Nick Mathewson
2007-11-05 23:34:39 +00:00
parent 9a20a64b62
commit 6fcda5299f
5 changed files with 45 additions and 22 deletions
+4 -8
View File
@@ -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;
}