From: teor Date: Sun, 19 Feb 2017 11:45:25 +0000 (+1100) Subject: Add unit tests for version parsing integer size inconsistencies X-Git-Tag: tor-0.3.1.1-alpha~253^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b3e139581ba7918668bd32bd7ef64a16eff2b9d2;p=thirdparty%2Ftor.git Add unit tests for version parsing integer size inconsistencies Unit tests for #21450. Part of #21470. --- 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, \