diff options
author | teor <teor2345@gmail.com> | 2017-02-19 22:47:47 +1100 |
---|---|---|
committer | teor <teor2345@gmail.com> | 2017-02-19 22:47:47 +1100 |
commit | 590bfe3d6df3c2cdcd8acde7444ec1a8e9ac8344 (patch) | |
tree | 456aefca1e407e0d5f5d80086b01207575b103a2 /src/test/test_dir.c | |
parent | 6d0b1a89971e1ee104ab758cb6aabeab70a7ffd9 (diff) | |
download | tor-590bfe3d6df3c2cdcd8acde7444ec1a8e9ac8344.tar.gz tor-590bfe3d6df3c2cdcd8acde7444ec1a8e9ac8344.zip |
Reject versions that have non-numeric prefixes
Unit tests #21507.
Part of #21470.
Diffstat (limited to 'src/test/test_dir.c')
-rw-r--r-- | src/test/test_dir.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/test/test_dir.c b/src/test/test_dir.c index d3ec9beaa8..696d61cfb5 100644 --- a/src/test/test_dir.c +++ b/src/test/test_dir.c @@ -1123,6 +1123,16 @@ test_dir_versions(void *arg) tt_int_op(-1, OP_EQ, tor_version_parse("0.-1.0", &ver1)); tt_int_op(-1, OP_EQ, tor_version_parse("0.-2147483648.0", &ver1)); tt_int_op(-1, OP_EQ, tor_version_parse("0.-4294967295.0", &ver1)); + /* In #21507, we reject version components with non-numeric prefixes */ + tt_int_op(-1, OP_EQ, tor_version_parse("0.-0.0", &ver1)); + tt_int_op(-1, OP_EQ, tor_version_parse("+1.0.0", &ver1)); + /* use the list in isspace() */ + tt_int_op(-1, OP_EQ, tor_version_parse("0.\t0.0", &ver1)); + tt_int_op(-1, OP_EQ, tor_version_parse("0.\n0.0", &ver1)); + tt_int_op(-1, OP_EQ, tor_version_parse("0.\v0.0", &ver1)); + tt_int_op(-1, OP_EQ, tor_version_parse("0.\f0.0", &ver1)); + tt_int_op(-1, OP_EQ, tor_version_parse("0.\r0.0", &ver1)); + tt_int_op(-1, OP_EQ, tor_version_parse("0. 0.0", &ver1)); #define tt_versionstatus_op(vs1, op, vs2) \ tt_assert_test_type(vs1,vs2,#vs1" "#op" "#vs2,version_status_t, \ |