From a46e5d3237c7cdeb7a6fad4dc22e4c60d2c28f65 Mon Sep 17 00:00:00 2001 From: Zdenek Dohnal Date: Thu, 22 Sep 2022 16:55:36 +0200 Subject: [PATCH] 2125823 - qpdf-11.1.0 is available, move to cmake --- .gitignore | 2 + 0001-Fix-tests-with-GNU-grep-3.8.patch | 37 ----- qpdf-relax.patch | 219 +++++++++++++------------ qpdf-s390x-disable-streamtest.patch | 35 ++-- qpdf.spec | 44 ++--- sources | 4 +- 6 files changed, 148 insertions(+), 193 deletions(-) delete mode 100644 0001-Fix-tests-with-GNU-grep-3.8.patch diff --git a/.gitignore b/.gitignore index f6c4993..b186531 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,5 @@ /qpdf-10.6.2.tar.gz /qpdf-10.6.3-doc.zip /qpdf-10.6.3.tar.gz +/qpdf-11.1.0-doc.zip +/qpdf-11.1.0.tar.gz diff --git a/0001-Fix-tests-with-GNU-grep-3.8.patch b/0001-Fix-tests-with-GNU-grep-3.8.patch deleted file mode 100644 index 561dcef..0000000 --- a/0001-Fix-tests-with-GNU-grep-3.8.patch +++ /dev/null @@ -1,37 +0,0 @@ -diff --git a/build-scripts/build-doc b/build-scripts/build-doc -index 077f836..18f85ee 100755 ---- a/build-scripts/build-doc -+++ b/build-scripts/build-doc -@@ -10,7 +10,7 @@ pip3 install sphinx sphinx_rtd_theme - ./configure --enable-doc-maintenance - make -j$(nproc) doc-dist DOC_DEST=doc - zip -r doc.zip doc --version=$(egrep '^release' manual/conf.py | cut -d"'" -f 2) -+version=$(grep -E '^release' manual/conf.py | cut -d"'" -f 2) - mv doc qpdf-${version}-doc - mkdir distribution - zip -r distribution/qpdf-${version}-doc.zip qpdf-${version}-doc -diff --git a/qpdf/qtest/qpdf/diff-encrypted b/qpdf/qtest/qpdf/diff-encrypted -index ac5428c..f6741c2 100755 ---- a/qpdf/qtest/qpdf/diff-encrypted -+++ b/qpdf/qtest/qpdf/diff-encrypted -@@ -1,5 +1,5 @@ - #!/bin/sh --lines=$(expr 0 + $(diff "$1" "$2" | egrep '^[<>]' | egrep -v '(Date|InstanceID)' | wc -l)) -+lines=$(expr 0 + $(diff "$1" "$2" | grep -E '^[<>]' | grep -E -v '(Date|InstanceID)' | wc -l)) - if [ "$lines" = "0" ]; then - echo okay - else -diff --git a/qpdf/qtest/qpdf/diff-ignore-ID-version b/qpdf/qtest/qpdf/diff-ignore-ID-version -index 72def44..de4c7c9 100755 ---- a/qpdf/qtest/qpdf/diff-ignore-ID-version -+++ b/qpdf/qtest/qpdf/diff-ignore-ID-version -@@ -1,6 +1,6 @@ - #!/bin/sh --lines=$(expr 0 + $(diff "$1" "$2" | egrep '^[<>]' | \ -- egrep -v '/ID' | egrep -v '%PDF-' | wc -l)) -+lines=$(expr 0 + $(diff "$1" "$2" | grep -E '^[<>]' | \ -+ grep -E -v '/ID' | grep -E -v '%PDF-' | wc -l)) - if [ "$lines" = "0" ]; then - echo okay - else diff --git a/qpdf-relax.patch b/qpdf-relax.patch index 6463134..a39f1db 100644 --- a/qpdf-relax.patch +++ b/qpdf-relax.patch @@ -1,59 +1,128 @@ -diff -up qpdf-10.6.3/libqpdf/QPDF.cc.relax qpdf-10.6.3/libqpdf/QPDF.cc ---- qpdf-10.6.3/libqpdf/QPDF.cc.relax 2022-03-08 18:32:06.000000000 +0100 -+++ qpdf-10.6.3/libqpdf/QPDF.cc 2022-07-14 17:08:35.395724219 +0200 +diff --git a/libqpdf/QPDF.cc b/libqpdf/QPDF.cc +index dd6037c..2a26a85 100644 +--- a/libqpdf/QPDF.cc ++++ b/libqpdf/QPDF.cc @@ -13,6 +13,10 @@ - #include - #include + #include + #include +#ifdef USE_CRYPTO_GNUTLS +# include +#endif + - #include - #include - #include -@@ -270,7 +274,13 @@ QPDF::processFile(char const* filename, + #include + #include + #include +@@ -279,7 +283,13 @@ void + QPDF::processFile(char const* filename, char const* password) { - FileInputSource* fi = new FileInputSource(); - fi->setFilename(filename); + FileInputSource* fi = new FileInputSource(filename); +#ifdef USE_CRYPTO_GNUTLS + GNUTLS_FIPS140_SET_LAX_MODE(); +#endif - processInputSource(PointerHolder(fi), password); + processInputSource(std::shared_ptr(fi), password); +#ifdef USE_CRYPTO_GNUTLS + GNUTLS_FIPS140_SET_STRICT_MODE(); +#endif } void -@@ -279,7 +289,13 @@ QPDF::processFile(char const* descriptio +@@ -287,7 +297,13 @@ QPDF::processFile( + char const* description, FILE* filep, bool close_file, char const* password) { - FileInputSource* fi = new FileInputSource(); - fi->setFile(description, filep, close_file); + FileInputSource* fi = new FileInputSource(description, filep, close_file); +#ifdef USE_CRYPTO_GNUTLS + GNUTLS_FIPS140_SET_LAX_MODE(); +#endif - processInputSource(PointerHolder(fi), password); + processInputSource(std::shared_ptr(fi), password); +#ifdef USE_CRYPTO_GNUTLS + GNUTLS_FIPS140_SET_STRICT_MODE(); +#endif } void -diff -up qpdf-10.6.3/libqpdf/QPDF_encryption.cc.relax qpdf-10.6.3/libqpdf/QPDF_encryption.cc ---- qpdf-10.6.3/libqpdf/QPDF_encryption.cc.relax 2022-03-08 18:32:06.000000000 +0100 -+++ qpdf-10.6.3/libqpdf/QPDF_encryption.cc 2022-07-14 17:10:08.450106652 +0200 -@@ -1,6 +1,8 @@ - // This file implements methods from the QPDF class that involve - // encryption. +diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc +index aad536b..ab02371 100644 +--- a/libqpdf/QPDFWriter.cc ++++ b/libqpdf/QPDFWriter.cc +@@ -25,6 +25,10 @@ + #include + #include + ++#ifdef USE_CRYPTO_GNUTLS ++#include ++#endif ++ + QPDFWriter::ProgressReporter::~ProgressReporter() + { + // Must be explicit and not inline -- see QPDF_DLL_CLASS in +@@ -342,6 +346,13 @@ void + QPDFWriter::setDeterministicID(bool val) + { + this->m->deterministic_id = val; ++ ++#ifdef USE_CRYPTO_GNUTLS ++ if (val) ++ GNUTLS_FIPS140_SET_LAX_MODE(); ++ else ++ GNUTLS_FIPS140_SET_STRICT_MODE(); ++#endif + } + + void +@@ -362,6 +373,13 @@ void + QPDFWriter::setPreserveEncryption(bool val) + { + this->m->preserve_encryption = val; ++ ++#ifdef USE_CRYPTO_GNUTLS ++ if (val) ++ GNUTLS_FIPS140_SET_STRICT_MODE(); ++ else ++ GNUTLS_FIPS140_SET_LAX_MODE(); ++#endif + } + + void +@@ -2109,12 +2127,23 @@ QPDFWriter::generateID() + } + } + ++#ifdef USE_CRYPTO_GNUTLS ++ unsigned oldmode = gnutls_fips140_mode_enabled(); ++ ++ gnutls_fips140_set_mode(GNUTLS_FIPS140_LAX, GNUTLS_FIPS140_SET_MODE_THREAD); ++#endif ++ + MD5 m; + m.encodeString(seed.c_str()); + MD5::Digest digest; + m.digest(digest); + result = + std::string(reinterpret_cast(digest), sizeof(MD5::Digest)); ++ ++#ifdef USE_CRYPTO_GNUTLS ++ gnutls_fips140_set_mode(static_cast(oldmode), GNUTLS_FIPS140_SET_MODE_THREAD); ++#endif ++ + } + + // If /ID already exists, follow the spec: use the original first +diff --git a/libqpdf/QPDF_encryption.cc b/libqpdf/QPDF_encryption.cc +index 266907a..658a353 100644 +--- a/libqpdf/QPDF_encryption.cc ++++ b/libqpdf/QPDF_encryption.cc +@@ -3,6 +3,8 @@ + + #include +#include + #include #include -@@ -18,6 +20,10 @@ - #include +@@ -19,6 +21,10 @@ + #include #include +#ifdef USE_CRYPTO_GNUTLS @@ -61,9 +130,9 @@ diff -up qpdf-10.6.3/libqpdf/QPDF_encryption.cc.relax qpdf-10.6.3/libqpdf/QPDF_e +#endif + static unsigned char const padding_string[] = { - 0x28, 0xbf, 0x4e, 0x5e, 0x4e, 0x75, 0x8a, 0x41, - 0x64, 0x00, 0x4e, 0x56, 0xff, 0xfa, 0x01, 0x08, -@@ -379,10 +385,21 @@ QPDF::compute_data_key(std::string const + 0x28, 0xbf, 0x4e, 0x5e, 0x4e, 0x75, 0x8a, 0x41, 0x64, 0x00, 0x4e, + 0x56, 0xff, 0xfa, 0x01, 0x08, 0x2e, 0x2e, 0x00, 0xb6, 0xd0, 0x68, +@@ -367,10 +373,21 @@ QPDF::compute_data_key( result += "sAlT"; } @@ -82,12 +151,12 @@ diff -up qpdf-10.6.3/libqpdf/QPDF_encryption.cc.relax qpdf-10.6.3/libqpdf/QPDF_e + gnutls_fips140_set_mode(static_cast(oldmode), GNUTLS_FIPS140_SET_MODE_THREAD); +#endif + - return std::string(reinterpret_cast(digest), - std::min(result.length(), toS(16))); + return std::string( + reinterpret_cast(digest), std::min(result.length(), toS(16))); } -@@ -1149,6 +1166,12 @@ QPDF::getKeyForObject( +@@ -1100,6 +1117,12 @@ QPDF::getKeyForObject( void - QPDF::decryptString(std::string& str, int objid, int generation) + QPDF::decryptString(std::string& str, QPDFObjGen const& og) { +#ifdef USE_CRYPTO_GNUTLS + unsigned oldmode = gnutls_fips140_mode_enabled(); @@ -95,12 +164,12 @@ diff -up qpdf-10.6.3/libqpdf/QPDF_encryption.cc.relax qpdf-10.6.3/libqpdf/QPDF_e + gnutls_fips140_set_mode(GNUTLS_FIPS140_LAX, GNUTLS_FIPS140_SET_MODE_THREAD); +#endif + - if (objid == 0) - { + if (!og.isIndirect()) { return; -@@ -1229,6 +1252,10 @@ QPDF::decryptString(std::string& str, in - QUtil::int_to_string(objid) + " " + - QUtil::int_to_string(generation) + ": " + e.what()); + } +@@ -1174,6 +1197,10 @@ QPDF::decryptString(std::string& str, QPDFObjGen const& og) + "error decrypting string for object " + og.unparse() + ": " + + e.what()); } + +#ifdef USE_CRYPTO_GNUTLS @@ -109,9 +178,9 @@ diff -up qpdf-10.6.3/libqpdf/QPDF_encryption.cc.relax qpdf-10.6.3/libqpdf/QPDF_e } void -@@ -1239,6 +1266,12 @@ QPDF::decryptStream(PointerHolder>& heap) +@@ -1186,6 +1213,12 @@ QPDF::decryptStream( + QPDFObjectHandle& stream_dict, + std::vector>& heap) { +#ifdef USE_CRYPTO_GNUTLS + unsigned oldmode = gnutls_fips140_mode_enabled(); @@ -120,9 +189,9 @@ diff -up qpdf-10.6.3/libqpdf/QPDF_encryption.cc.relax qpdf-10.6.3/libqpdf/QPDF_e +#endif + std::string type; - if (stream_dict.getKey("/Type").isName()) - { -@@ -1361,6 +1394,10 @@ QPDF::decryptStream(PointerHolder - #include - -+#ifdef USE_CRYPTO_GNUTLS -+#include -+#endif -+ - QPDFWriter::Members::Members(QPDF& pdf) : - pdf(pdf), - filename("unspecified"), -@@ -339,6 +343,13 @@ void - QPDFWriter::setDeterministicID(bool val) - { - this->m->deterministic_id = val; -+ -+#ifdef USE_CRYPTO_GNUTLS -+ if (val) -+ GNUTLS_FIPS140_SET_LAX_MODE(); -+ else -+ GNUTLS_FIPS140_SET_STRICT_MODE(); -+#endif - } - - void -@@ -360,6 +371,13 @@ void - QPDFWriter::setPreserveEncryption(bool val) - { - this->m->preserve_encryption = val; -+ -+#ifdef USE_CRYPTO_GNUTLS -+ if (val) -+ GNUTLS_FIPS140_SET_STRICT_MODE(); -+ else -+ GNUTLS_FIPS140_SET_LAX_MODE(); -+#endif - } - - void -@@ -2311,12 +2329,23 @@ QPDFWriter::generateID() - } - } - -+#ifdef USE_CRYPTO_GNUTLS -+ unsigned oldmode = gnutls_fips140_mode_enabled(); -+ -+ gnutls_fips140_set_mode(GNUTLS_FIPS140_LAX, GNUTLS_FIPS140_SET_MODE_THREAD); -+#endif -+ - MD5 m; - m.encodeString(seed.c_str()); - MD5::Digest digest; - m.digest(digest); - result = std::string(reinterpret_cast(digest), - sizeof(MD5::Digest)); -+ -+#ifdef USE_CRYPTO_GNUTLS -+ gnutls_fips140_set_mode(static_cast(oldmode), GNUTLS_FIPS140_SET_MODE_THREAD); -+#endif -+ - } - - // If /ID already exists, follow the spec: use the original first diff --git a/qpdf-s390x-disable-streamtest.patch b/qpdf-s390x-disable-streamtest.patch index db032fd..6be86b1 100644 --- a/qpdf-s390x-disable-streamtest.patch +++ b/qpdf-s390x-disable-streamtest.patch @@ -1,7 +1,8 @@ -diff -up qpdf-10.4.0/libqpdf/QPDFWriter.cc.s390x-disable-streamtest qpdf-10.4.0/libqpdf/QPDFWriter.cc ---- qpdf-10.4.0/libqpdf/QPDFWriter.cc.s390x-disable-streamtest 2021-12-06 12:53:11.625309618 +0100 -+++ qpdf-10.4.0/libqpdf/QPDFWriter.cc 2021-12-06 12:53:11.627309604 +0100 -@@ -2096,7 +2096,6 @@ QPDFWriter::writeObjectStream(QPDFObject +diff --git a/libqpdf/QPDFWriter.cc b/libqpdf/QPDFWriter.cc +index ab02371..ce5f7ff 100644 +--- a/libqpdf/QPDFWriter.cc ++++ b/libqpdf/QPDFWriter.cc +@@ -1926,7 +1926,6 @@ QPDFWriter::writeObjectStream(QPDFObjectHandle object) // This condition occurred in a fuzz input. Ideally we // should block it at at parse time, but it's not // clear to me how to construct a case for this. @@ -9,25 +10,27 @@ diff -up qpdf-10.4.0/libqpdf/QPDFWriter.cc.s390x-disable-streamtest qpdf-10.4.0/ obj_to_write.warnIfPossible( "stream found inside object stream; treating as null"); obj_to_write = QPDFObjectHandle::newNull(); -diff -up qpdf-10.4.0/qpdf/qpdf.testcov.s390x-disable-streamtest qpdf-10.4.0/qpdf/qpdf.testcov ---- qpdf-10.4.0/qpdf/qpdf.testcov.s390x-disable-streamtest 2021-11-16 21:44:09.000000000 +0100 -+++ qpdf-10.4.0/qpdf/qpdf.testcov 2021-12-06 12:53:11.628309596 +0100 -@@ -442,7 +442,6 @@ QPDF xref skipped space 0 +diff --git a/qpdf/qpdf.testcov b/qpdf/qpdf.testcov +index e89f63a..6e3582c 100644 +--- a/qpdf/qpdf.testcov ++++ b/qpdf/qpdf.testcov +@@ -427,7 +427,6 @@ QPDF xref skipped space 0 QPDF eof skipping spaces before xref 1 QPDF_encryption user matches owner V < 5 0 QPDF_encryption same password 1 -QPDFWriter stream in ostream 0 - QPDFObjectHandle duplicate dict key 0 + QPDFParser duplicate dict key 0 QPDFWriter no encryption sig contents 0 QPDFPageObjectHelper colorspace lookup 0 -diff -up qpdf-10.4.0/qpdf/qtest/qpdf.test.s390x-disable-streamtest qpdf-10.4.0/qpdf/qtest/qpdf.test ---- qpdf-10.4.0/qpdf/qtest/qpdf.test.s390x-disable-streamtest 2021-12-06 12:53:11.628309596 +0100 -+++ qpdf-10.4.0/qpdf/qtest/qpdf.test 2021-12-06 12:54:45.351620347 +0100 -@@ -1024,7 +1024,6 @@ my @bug_tests = ( +diff --git a/qpdf/qtest/specific-bugs.test b/qpdf/qtest/specific-bugs.test +index 326b3e9..f9665cb 100644 +--- a/qpdf/qtest/specific-bugs.test ++++ b/qpdf/qtest/specific-bugs.test +@@ -38,7 +38,6 @@ my @bug_tests = ( ["263", "empty xref stream", 2], ["335a", "ozz-fuzz-12152", 2], ["335b", "ozz-fuzz-14845", 2], - ["fuzz-16214", "stream in object stream", 3, "--preserve-unreferenced"], - # When adding to this list, consider adding to CORPUS_FROM_TEST - # in fuzz/build.mk and updating the count in fuzz/qtest/fuzz.test. - ); + # When adding to this list, consider adding to CORPUS_FROM_TEST in + # fuzz/CMakeLists.txt and updating the count in + # fuzz/qtest/fuzz.test. diff --git a/qpdf.spec b/qpdf.spec index c2d7093..5f5d352 100644 --- a/qpdf.spec +++ b/qpdf.spec @@ -1,7 +1,7 @@ Summary: Command-line tools and library for transforming PDF files Name: qpdf -Version: 10.6.3 -Release: 5%{?dist} +Version: 11.1.0 +Release: 1%{?dist} # MIT: e.g. libqpdf/sha2.c # upstream uses ASL 2.0 now, but he allowed other to distribute qpdf under # old license (see README) @@ -15,17 +15,14 @@ Patch1: qpdf-relax.patch # now we have s390x specific patch in zlib which changes output # so we need to disable one test because of it Patch2: qpdf-s390x-disable-streamtest.patch -# egrep now shows warning, which causes test failure. Move to `grep -E` -# https://github.com/qpdf/qpdf/commit/7049588bff21e3ea3e7bf3c4a4325c8ab4ed46f8 -Patch3: 0001-Fix-tests-with-GNU-grep-3.8.patch # gcc and gcc-c++ are no longer in buildroot by default # gcc is needed for qpdf-ctest.c BuildRequires: gcc # gcc-c++ is need for everything except for qpdf-ctest BuildRequires: gcc-c++ -# uses make -BuildRequires: make +# uses cmake +BuildRequires: cmake BuildRequires: zlib-devel BuildRequires: libjpeg-turbo-devel @@ -43,6 +40,7 @@ BuildRequires: perl(Cwd) BuildRequires: perl(Digest::MD5) BuildRequires: perl(Digest::SHA) BuildRequires: perl(File::Basename) +BuildRequires: perl(File::Compare) BuildRequires: perl(File::Copy) BuildRequires: perl(File::Find) BuildRequires: perl(File::Spec) @@ -55,11 +53,6 @@ BuildRequires: perl(strict) # perl(Term::ANSIColor) - not needed for tests # perl(Term::ReadKey) - not needed for tests -# for autoreconf -BuildRequires: autoconf -BuildRequires: automake -BuildRequires: libtool - Requires: %{name}-libs%{?_isa} = %{version}-%{release} %package libs @@ -101,36 +94,24 @@ QPDF Manual %ifarch s390x %patch2 -p1 -b .s390x-disable-streamtest %endif -%patch3 -p1 -b .use-grepe # unpack zip file with manual unzip %{SOURCE1} %build -# work-around check-rpaths errors -autoreconf --verbose --force --install -# automake files needed to be regenerated in 8.4.0 - check if this can be removed -# in the next qpdf release -./autogen.sh +%cmake -DBUILD_STATIC_LIBS=0 -DREQUIRE_CRYPTO_GNUTLS=1 -DUSE_IMPLICIT_CRYPTO=0 -DSHOW_FAILED_TEST_OUTPUT=1 -DINSTALL_CMAKE_PACKAGE=0 -%configure --disable-static \ - --enable-crypto-gnutls \ - --disable-implicit-crypto \ - --enable-show-failed-test-output - -%make_build +%cmake_build %install -%make_install +%cmake_install install -m 0644 %{name}-%{version}-doc/%{name}-manual.pdf %{buildroot}/%{_pkgdocdir}/%{name}-manual.pdf -rm -f %{buildroot}%{_libdir}/libqpdf.la - %check -make check +%ctest %ldconfig_scriptlets libs @@ -143,8 +124,8 @@ make check %files libs %doc README.md TODO ChangeLog %license Artistic-2.0 -%{_libdir}/libqpdf.so.28 -%{_libdir}/libqpdf.so.28.6.3 +%{_libdir}/libqpdf.so.29 +%{_libdir}/libqpdf.so.29.1.0 %files devel %doc examples/*.cc examples/*.c @@ -157,6 +138,9 @@ make check %changelog +* Thu Sep 22 2022 Zdenek Dohnal - 11.1.0-1 +- 2125823 - qpdf-11.1.0 is available, move to cmake + * Thu Sep 22 2022 Zdenek Dohnal - 10.6.3-5 - use `grep -E` in test suite (bz2127957) diff --git a/sources b/sources index aed5b39..89ceefc 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (qpdf-10.6.3-doc.zip) = 780c25df78bc0360a17de85b0701f2e929677b02989d47c6e26b57749dd2315bb21511de9d8d40670a4745254c5c17fcf1c649233be1a0255b5a661f5dcda61b -SHA512 (qpdf-10.6.3.tar.gz) = c584b7443984b0f28eec2fbff054096b9a14a10858dda0c6b370d7a19e34c395ee15a8dc0770d3d85773281cd79944f029fb3bfad55833a2c32ff7e1a751c149 +SHA512 (qpdf-11.1.0-doc.zip) = 300dca6495ff9770138b7166e584cff1f2d26c60f273030211a895cf0f0147124240c2f22e79fae4f66595b863e2ce9dcdd7e8144c8b64357bf9a9e9b92ca6ea +SHA512 (qpdf-11.1.0.tar.gz) = 4c4daf3e6ae40e57d0d099abb7c9e694b7bec0c6657ffa4dc084f295d57799b8a5cbe5827d346fcbb89fa88a84c4dbd9a5437cc649b617cd479231c9ecc3fb5a