summaryrefslogtreecommitdiff
path: root/src/or/routerparse.c
diff options
context:
space:
mode:
authorRobert Ransom <rransom.8774@gmail.com>2012-09-13 07:39:39 -0400
committerRobert Ransom <rransom.8774@gmail.com>2012-09-13 07:48:21 -0400
commit0a6480cdd00fbed2eba0e5bab6ef82bc809c665b (patch)
tree9e4ba0a8f26be20baa70e393132358905f077b2d /src/or/routerparse.c
parent45439bfced7f41c2e0beecb715880cb83d421618 (diff)
downloadtor-0a6480cdd00fbed2eba0e5bab6ef82bc809c665b.tar.gz
tor-0a6480cdd00fbed2eba0e5bab6ef82bc809c665b.zip
Avoid undefined behaviour when parsing HS protocol versions
Fixes bug 6827; bugfix on c58675ca728f12b42f65e5b8964ae695c2e0ec2d (when the v2 HS desc parser was implemented). Found by asn.
Diffstat (limited to 'src/or/routerparse.c')
-rw-r--r--src/or/routerparse.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 60a2eae75f..2bf072b3cf 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -4823,6 +4823,9 @@ rend_parse_v2_service_descriptor(rend_service_descriptor_t **parsed_out,
10, 0, INT_MAX, &num_ok, NULL);
if (!num_ok) /* It's a string; let's ignore it. */
continue;
+ if (version >= REND_PROTOCOL_VERSION_BITMASK_WIDTH)
+ /* Avoid undefined left-shift behaviour. */
+ continue;
result->protocols |= 1 << version;
}
SMARTLIST_FOREACH(versions, char *, cp, tor_free(cp));