diff options
author | teor <teor2345@gmail.com> | 2017-02-19 22:45:25 +1100 |
---|---|---|
committer | teor <teor2345@gmail.com> | 2017-02-19 22:45:25 +1100 |
commit | b3e139581ba7918668bd32bd7ef64a16eff2b9d2 (patch) | |
tree | fe4250c0296b864375e2db1c4545d326d5fa6e19 /src/test/test_dir.c | |
parent | e34a209df1652be5f15083ff8d6e44316fe1a599 (diff) | |
download | tor-b3e139581ba7918668bd32bd7ef64a16eff2b9d2.tar.gz tor-b3e139581ba7918668bd32bd7ef64a16eff2b9d2.zip |
Add unit tests for version parsing integer size inconsistencies
Unit tests for #21450.
Part of #21470.
Diffstat (limited to 'src/test/test_dir.c')
-rw-r--r-- | src/test/test_dir.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/test/test_dir.c b/src/test/test_dir.c index a16aa2f480..d72977df60 100644 --- a/src/test/test_dir.c +++ b/src/test/test_dir.c @@ -1107,6 +1107,18 @@ test_dir_versions(void *arg) tt_int_op(9, OP_EQ, ver1.patchlevel); tt_int_op(VER_RELEASE, OP_EQ, ver1.status); tt_str_op("dev", OP_EQ, ver1.status_tag); + /* In #21450, we fixed an inconsistency in parsing versions > INT32_MAX + * between i386 and x86_64, as we used tor_parse_long, and then cast to int + */ + tt_int_op(0, OP_EQ, tor_version_parse("0.2147483647.0", &ver1)); + tt_int_op(0, OP_EQ, ver1.major); + tt_int_op(2147483647, OP_EQ, ver1.minor); + tt_int_op(0, OP_EQ, ver1.micro); + tt_int_op(0, OP_EQ, ver1.patchlevel); + tt_int_op(VER_RELEASE, OP_EQ, ver1.status); + tt_str_op("", OP_EQ, ver1.status_tag); + 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)); #define tt_versionstatus_op(vs1, op, vs2) \ tt_assert_test_type(vs1,vs2,#vs1" "#op" "#vs2,version_status_t, \ |