summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2018-06-08 10:11:57 -0400
committerNick Mathewson <nickm@torproject.org>2018-06-08 10:11:57 -0400
commitaef0607f3810ef47f0b13b5ed1d553578940dd7c (patch)
tree2195ee8bb5e8262949c3303e31df2b7b51a62019
parent3716ddf1b42270b5db76f8b7b458c5f61aa40e23 (diff)
parentc27bb4072ca25b154e100158f819315bd8683ce0 (diff)
downloadtor-aef0607f3810ef47f0b13b5ed1d553578940dd7c.tar.gz
tor-aef0607f3810ef47f0b13b5ed1d553578940dd7c.zip
Merge branch 'maint-0.3.3'
-rw-r--r--changes/bug261964
-rw-r--r--src/or/protover.c13
2 files changed, 17 insertions, 0 deletions
diff --git a/changes/bug26196 b/changes/bug26196
new file mode 100644
index 0000000000..47fcffa0f8
--- /dev/null
+++ b/changes/bug26196
@@ -0,0 +1,4 @@
+ o Minor bugfixes (hardening):
+ - Prevent a possible out-of-bounds smartlist read in
+ protover_compute_vote(). Fixes bug 26196; bugfix on
+ 0.2.9.4-alpha.
diff --git a/src/or/protover.c b/src/or/protover.c
index b2f4a8f4b6..e4efe0a70b 100644
--- a/src/or/protover.c
+++ b/src/or/protover.c
@@ -529,6 +529,10 @@ cmp_single_ent_by_version(const void **a_, const void **b_)
static char *
contract_protocol_list(const smartlist_t *proto_strings)
{
+ if (smartlist_len(proto_strings) == 0) {
+ return tor_strdup("");
+ }
+
// map from name to list of single-version entries
strmap_t *entry_lists_by_name = strmap_new();
// list of protocol names
@@ -637,6 +641,10 @@ char *
protover_compute_vote(const smartlist_t *list_of_proto_strings,
int threshold)
{
+ if (smartlist_len(list_of_proto_strings) == 0) {
+ return tor_strdup("");
+ }
+
smartlist_t *all_entries = smartlist_new();
// First, parse the inputs and break them into singleton entries.
@@ -663,6 +671,11 @@ protover_compute_vote(const smartlist_t *list_of_proto_strings,
smartlist_free(unexpanded);
} SMARTLIST_FOREACH_END(vote);
+ if (smartlist_len(all_entries) == 0) {
+ smartlist_free(all_entries);
+ return tor_strdup("");
+ }
+
// Now sort the singleton entries
smartlist_sort_strings(all_entries);