commit 32b33c0d21ce471d735abbedc26d26998238c380 Author: cypherpunks cypherpunks@torproject.org Date: Fri Aug 17 22:45:33 2018 +0000
protover: reject unexpected commas
Consistently reject extra commas, instead of only rejecting leading commas.
Fix on b2b2e1c7f24d9b65059e3d089768d6c49ba4f58f. Fixes #27194; bugfix on 0.2.9.4-alpha. --- changes/bug27194 | 3 +++ src/core/or/protover.c | 3 ++- src/test/test_protover.c | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/changes/bug27194 b/changes/bug27194 new file mode 100644 index 0000000000..a1919c6c49 --- /dev/null +++ b/changes/bug27194 @@ -0,0 +1,3 @@ + o Minor bugfixes (protover): + - Consistently reject extra commas, instead of only rejecting leading commas. + Fixes bug 27194; bugfix on 0.2.9.4-alpha. diff --git a/src/core/or/protover.c b/src/core/or/protover.c index 17979d04ea..763eadadf9 100644 --- a/src/core/or/protover.c +++ b/src/core/or/protover.c @@ -245,7 +245,8 @@ parse_single_entry(const char *s, const char *end_of_entry) }
s = comma; - while (*s == ',' && s < end_of_entry) + // Skip the comma separator between ranges. Don't ignore a trailing comma. + if (s < (end_of_entry - 1)) ++s; }
diff --git a/src/test/test_protover.c b/src/test/test_protover.c index 63c508bd13..664576f625 100644 --- a/src/test/test_protover.c +++ b/src/test/test_protover.c @@ -572,6 +572,10 @@ test_protover_vote_roundtrip(void *args) { "N-1=1,2", "N-1=1-2" }, { "-1=4294967295", NULL }, { "-1=3", "-1=3" }, + { "Foo=,", NULL }, + { "Foo=,1", NULL }, + { "Foo=1,,3", NULL }, + { "Foo=1,3,", NULL }, /* junk. */ { "!!3@*", NULL }, /* Missing equals sign */