From d71f05ca07eb5c7cfa4d6d23e5c1f2a800f52e8e Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Thu, 20 Jun 2019 23:35:23 -0400 Subject: 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. --- ChangeLog | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'ChangeLog') diff --git a/ChangeLog b/ChangeLog index a9196159..713b954a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,19 @@ 2019-06-20 Jay Berkenbilt + * Fix all integer sign and conversion warnings. This makes all + integer type conversions that have potential data loss explicit + with calls that do range checks and raise an exception. + * Change out_bufsize argument to Pl_Flate's constructor for int to unsigned int for compatibility with underlying zlib implementation. + * Change QPDFObjectHandle::pipeStreamData's encode_flags argument + from unsigned long to int since int is the underlying type of the + enumerated type values that are passed to it. This change should + be invisible to virtually all code unless you are compiling with + strict warning flags and explicitly casting to unsigned long. + * Add methods to QPDFObjectHandle to return the value of Integer objects as int and unsigned int with range checking and fallback behavior to avoid silent underflow/overflow conditions. -- cgit v1.2.3-54-g00ecf