aboutsummaryrefslogtreecommitdiffstats
path: root/libtests/qtest
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2019-06-21 05:35:23 +0200
committerJay Berkenbilt <ejb@ql.org>2019-06-21 19:17:21 +0200
commitd71f05ca07eb5c7cfa4d6d23e5c1f2a800f52e8e (patch)
tree60f4a13cbadee1a02a49f35f325460f2ad507c95 /libtests/qtest
parentf40ffc9d6392edf9b6fe74d288d6d578e6d1a240 (diff)
downloadqpdf-d71f05ca07eb5c7cfa4d6d23e5c1f2a800f52e8e.tar.zst
Fix sign and conversion warnings (major)
This makes all integer type conversions that have potential data loss explicit with calls that do range checks and raise an exception. After this commit, qpdf builds with no warnings when -Wsign-conversion -Wconversion is used with gcc or clang or when -W3 -Wd4800 is used with MSVC. This significantly reduces the likelihood of potential crashes from bogus integer values. There are some parts of the code that take int when they should take size_t or an offset. Such places would make qpdf not support files with more than 2^31 of something that usually wouldn't be so large. In the event that such a file shows up and is valid, at least qpdf would raise an error in the right spot so the issue could be legitimately addressed rather than failing in some weird way because of a silent overflow condition.
Diffstat (limited to 'libtests/qtest')
-rw-r--r--libtests/qtest/qintc/qintc.out2
-rw-r--r--libtests/qtest/qutil/qutil.out1
2 files changed, 2 insertions, 1 deletions
diff --git a/libtests/qtest/qintc/qintc.out b/libtests/qtest/qintc/qintc.out
index 9b6d35d9..5c6479e2 100644
--- a/libtests/qtest/qintc/qintc.out
+++ b/libtests/qtest/qintc/qintc.out
@@ -7,7 +7,7 @@ QIntC::to_int<uint64_t>(ul2): 12345 12345 PASSED
QIntC::to_uint<uint64_t>(ul2): 12345 12345 PASSED
QIntC::to_offset<uint32_t>(u1): 3141592653 3141592653 PASSED
QIntC::to_offset<int32_t>(i1): -1153374643 -1153374643 PASSED
-QIntC::to_size<int32_t>(i1): integer out of range converting -1153374643 from a 4-byte signed type to a 8-byte unsigned type PASSED
+QIntC::to_ulonglong<int32_t>(i1): integer out of range converting -1153374643 from a 4-byte signed type to a 8-byte unsigned type PASSED
QIntC::to_char<int32_t>(i2): 81 Q PASSED
QIntC::to_uchar<int32_t>(i2): 81 Q PASSED
QIntC::to_uchar<char>(c1): integer out of range converting ÷ from a 1-byte signed type to a 1-byte unsigned type PASSED
diff --git a/libtests/qtest/qutil/qutil.out b/libtests/qtest/qutil/qutil.out
index 4d19617d..2f270226 100644
--- a/libtests/qtest/qutil/qutil.out
+++ b/libtests/qtest/qutil/qutil.out
@@ -12,6 +12,7 @@
16059
37273
3ebb
+5000093552
one
7
compare okay