[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Add unit tests for version parsing integer size inconsistencies



commit b3e139581ba7918668bd32bd7ef64a16eff2b9d2
Author: teor <teor2345@xxxxxxxxx>
Date:   Sun Feb 19 22:45:25 2017 +1100

    Add unit tests for version parsing integer size inconsistencies
    
    Unit tests for #21450.
    Part of #21470.
---
 src/test/test_dir.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index a16aa2f..d72977d 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,       \



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits