[poppler] qt5/tests

2021-01-02 Thread GitLab Mirror
 qt5/tests/fuzzing/qt_pdf_fuzzer.cc |   22 ++
 1 file changed, 22 insertions(+)

New commits:
commit bae34cd97a94ff9aa7ad9458f04e494451828b0d
Author: Albert Astals Cid 
Date:   Sun Jan 3 01:42:06 2021 +0100

fuzz the ps converter code

diff --git a/qt5/tests/fuzzing/qt_pdf_fuzzer.cc 
b/qt5/tests/fuzzing/qt_pdf_fuzzer.cc
index 82786994..af081886 100644
--- a/qt5/tests/fuzzing/qt_pdf_fuzzer.cc
+++ b/qt5/tests/fuzzing/qt_pdf_fuzzer.cc
@@ -1,5 +1,6 @@
 #include 
 #include 
+#include 
 #include 
 
 static void dummy_error_function(const QString &, const QVariant &) { }
@@ -22,6 +23,27 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, 
size_t size)
 QImage image = p->renderToImage(72.0, 72.0, -1, -1, -1, -1, 
Poppler::Page::Rotate0);
 delete p;
 }
+
+if (doc->numPages() > 0) {
+QList pageList;
+for (int i = 0; i < doc->numPages(); i++) {
+pageList << (i + 1);
+}
+
+Poppler::PSConverter *psConverter = doc->psConverter();
+
+QBuffer buffer;
+buffer.open(QIODevice::WriteOnly);
+psConverter->setOutputDevice(&buffer);
+
+psConverter->setPageList(pageList);
+psConverter->setPaperWidth(595);
+psConverter->setPaperHeight(842);
+psConverter->setTitle(doc->info("Title"));
+psConverter->convert();
+delete psConverter;
+}
+
 delete doc;
 return 0;
 }
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] 3 commits - .gitlab-ci.yml poppler/CurlCachedFile.cc poppler/DateInfo.cc poppler/PSOutputDev.cc utils/HtmlOutputDev.cc

2021-01-02 Thread GitLab Mirror
 .gitlab-ci.yml|4 +++-
 poppler/CurlCachedFile.cc |6 +++---
 poppler/DateInfo.cc   |3 ++-
 poppler/PSOutputDev.cc|5 +++--
 utils/HtmlOutputDev.cc|4 ++--
 5 files changed, 13 insertions(+), 9 deletions(-)

New commits:
commit 04aa2f7e416eb232821576fec7ed61b0b7273fbc
Author: Albert Astals Cid 
Date:   Sun Jan 3 01:06:39 2021 +0100

CI: Enable goostring-format-checker clang checker

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index c99520d5..9c143682 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -53,7 +53,9 @@ build_clang_libcpp:
   script:
 - git clone --branch ${CI_COMMIT_REF_NAME} --depth 1 ${TEST_DATA_URL} 
test-data || git clone --depth 1 ${UPSTREAM_TEST_DATA_URL} test-data
 - mkdir -p build && cd build
-- CC=clang CXX=clang++ cmake -G Ninja -DCMAKE_CXX_FLAGS=-stdlib=libc++ 
-DTESTDATADIR=$PWD/../test-data 
-DCMAKE_CXX_CLANG_TIDY="clang-tidy;-header-filter=.;-checks=-*,performance-*,bugprone-*,readability-inconsistent-declaration-parameter-name,readability-string-compare,modernize-deprecated-headers,modernize-make-unique,modernize-make-shared,modernize-use-override,modernize-use-equals-delete,modernize-use-emplace,modernize-use-bool-literals,modernize-redundant-void-arg,modernize-loop-convert,-bugprone-narrowing-conversions,-bugprone-macro-parentheses,-bugprone-suspicious-string-compare,-bugprone-incorrect-roundings,-bugprone-undefined-memory-manipulation,-bugprone-sizeof-expression,-bugprone-branch-clone,-bugprone-reserved-identifier,-bugprone-suspicious-include;-warnings-as-errors=*"
 ..
+- apt-get install --yes --no-install-recommends libclang-dev llvm-dev
+- clang++ -fPIC -shared -o goostring-format-checker.so 
../test/goostring-format-checker/goostring-format-checker.cc 
-D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -I /usr/lib/llvm-11/include/
+- CC=clang CXX=clang++ cmake -G Ninja -DCMAKE_CXX_FLAGS="-stdlib=libc++ 
-Xclang -load -Xclang $PWD/goostring-format-checker.so -Xclang -add-plugin 
-Xclang goostring-format-checker" -DTESTDATADIR=$PWD/../test-data 
-DCMAKE_CXX_CLANG_TIDY="clang-tidy;-header-filter=.;-checks=-*,performance-*,bugprone-*,readability-inconsistent-declaration-parameter-name,readability-string-compare,modernize-deprecated-headers,modernize-make-unique,modernize-make-shared,modernize-use-override,modernize-use-equals-delete,modernize-use-emplace,modernize-use-bool-literals,modernize-redundant-void-arg,modernize-loop-convert,-bugprone-narrowing-conversions,-bugprone-macro-parentheses,-bugprone-suspicious-string-compare,-bugprone-incorrect-roundings,-bugprone-undefined-memory-manipulation,-bugprone-sizeof-expression,-bugprone-branch-clone,-bugprone-reserved-identifier,-bugprone-suspicious-include;-warnings-as-errors=*"
 ..
 - ninja
 - ctest --output-on-failure
 
commit 4d58ff810bb977855c55d4de7d75899aa9ef55b7
Author: Albert Astals Cid 
Date:   Sun Jan 3 01:05:01 2021 +0100

Change a few variables to types GooString::format knows about

None of them is problematic, but being more strict let's use enable the
goostring-format-checker clang plugin

diff --git a/poppler/CurlCachedFile.cc b/poppler/CurlCachedFile.cc
index d867626b..926a6f5b 100644
--- a/poppler/CurlCachedFile.cc
+++ b/poppler/CurlCachedFile.cc
@@ -6,7 +6,7 @@
 //
 // Copyright 2009 Stefan Thomas 
 // Copyright 2010, 2011 Hib Eris 
-// Copyright 2010, 2019 Albert Astals Cid 
+// Copyright 2010, 2019, 2021 Albert Astals Cid 
 //
 //
 
@@ -72,12 +72,12 @@ static size_t load_cb(const char *ptr, size_t size, size_t 
nmemb, void *data)
 int CurlCachedFileLoader::load(const std::vector &ranges, 
CachedFileWriter *writer)
 {
 CURLcode r = CURLE_OK;
-size_t fromByte, toByte;
+unsigned long long fromByte, toByte;
 for (const ByteRange &bRange : ranges) {
 
 fromByte = bRange.offset;
 toByte = fromByte + bRange.length - 1;
-GooString *range = GooString::format("{0:ud}-{1:ud}", fromByte, 
toByte);
+GooString *range = GooString::format("{0:ulld}-{1:ulld}", fromByte, 
toByte);
 
 curl_easy_setopt(curl, CURLOPT_URL, url->c_str());
 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, load_cb);
diff --git a/poppler/DateInfo.cc b/poppler/DateInfo.cc
index d277ee74..010a0dfb 100644
--- a/poppler/DateInfo.cc
+++ b/poppler/DateInfo.cc
@@ -8,6 +8,7 @@
 // Copyright (C) 2015 André Esser 
 // Copyright (C) 2016, 2018 Adrian Johnson 
 // Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, 
. Work sponsored by Technische Universität Dresden
+// Copyright (C) 2021 Albert Astals Cid 
 //
 // To see a description of the changes please see the Changelog file that
 // came with your tarball or type make ChangeLog if you are building from git
@@ -86,7 +87,7 @@ GooString *timeToDateString(const time_t *timeA)
 // calculate time zone offset by comparing local and gmtime time_t value 
for same
 // ti

[poppler] 2 commits - poppler/Form.cc

2021-01-02 Thread GitLab Mirror
 poppler/Form.cc |   48 +++-
 1 file changed, 35 insertions(+), 13 deletions(-)

New commits:
commit 3928dde50bfd44d340ef0cb302610cbcf9bece58
Author: Albert Astals Cid 
Date:   Sun Jan 3 00:09:22 2021 +0100

Account for fread potentially failing

diff --git a/poppler/Form.cc b/poppler/Form.cc
index 0941f4b7..06855785 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -510,7 +510,9 @@ static bool hashFileRange(FILE *f, SignatureHandler 
*handler, Goffset start, Gof
 int len = BUF_SIZE;
 if (end - start < len)
 len = end - start;
-fread(buf, len, 1, f);
+if (fread(buf, 1, len, f) != static_cast(len)) {
+return false;
+}
 handler->updateHash(buf, len);
 start += len;
 }
@@ -657,19 +659,21 @@ bool FormWidgetSignature::updateOffsets(FILE *f, Goffset 
objStart, Goffset objEn
 return false;
 }
 
-int bufSize = static_cast(objEnd - objStart);
+const size_t bufSize = static_cast(objEnd - objStart);
 if (Gfseek(f, objStart, SEEK_SET) != 0) {
 return false;
 }
 std::vector buf(bufSize + 1);
-fread(buf.data(), bufSize, 1, f);
+if (fread(buf.data(), 1, bufSize, f) != bufSize) {
+return false;
+}
 buf[bufSize] = 0; // prevent string functions from searching past the end
 
 // search for the Contents field which contains the signature
 // which always must start with hex digits 308
 *sigStart = -1;
 *sigEnd = -1;
-for (int i = 0; i < bufSize - 14; i++) {
+for (size_t i = 0; i < bufSize - 14; i++) {
 if (buf[i] == '/' && strncmp(&buf[i], "/Contents <308", 14) == 0) {
 *sigStart = objStart + i + 10;
 char *p = strchr(&buf[i], '>');
@@ -683,7 +687,7 @@ bool FormWidgetSignature::updateOffsets(FILE *f, Goffset 
objStart, Goffset objEn
 return false;
 
 // Search for ByteRange array and update offsets
-for (int i = 0; i < bufSize - 10; i++) {
+for (size_t i = 0; i < bufSize - 10; i++) {
 if (buf[i] == '/' && strncmp(&buf[i], "/ByteRange", 10) == 0) {
 // update range
 char *p = setNextOffset(&buf[i], *sigStart);
commit ec9420b76c6a1dfc7101b03f475fa0c91fa49a47
Author: Albert Astals Cid 
Date:   Sun Jan 3 00:04:17 2021 +0100

Account for Gfseek potentially failing

diff --git a/poppler/Form.cc b/poppler/Form.cc
index 5ee2d514..0941f4b7 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -496,14 +496,17 @@ SignatureInfo 
*FormWidgetSignature::validateSignature(bool doVerifyCert, bool fo
 
 #ifdef ENABLE_NSS3
 // update hash with the specified range of data from the file
-static void hashFileRange(FILE *f, SignatureHandler *handler, Goffset start, 
Goffset end)
+static bool hashFileRange(FILE *f, SignatureHandler *handler, Goffset start, 
Goffset end)
 {
 const int BUF_SIZE = 65536;
 
 unsigned char *buf = new unsigned char[BUF_SIZE];
 
 while (start < end) {
-Gfseek(f, start, SEEK_SET);
+if (Gfseek(f, start, SEEK_SET) != 0) {
+delete[] buf;
+return false;
+}
 int len = BUF_SIZE;
 if (end - start < len)
 len = end - start;
@@ -512,6 +515,7 @@ static void hashFileRange(FILE *f, SignatureHandler 
*handler, Goffset start, Gof
 start += len;
 }
 delete[] buf;
+return true;
 }
 #endif
 
@@ -570,8 +574,14 @@ bool FormWidgetSignature::signDocument(const char 
*saveFilename, const char *cer
 
 // compute hash of byte ranges
 sigHandler.restartHash();
-hashFileRange(file, &sigHandler, 0LL, sigStart);
-hashFileRange(file, &sigHandler, sigEnd, fileSize);
+if (!hashFileRange(file, &sigHandler, 0LL, sigStart)) {
+fclose(file);
+return false;
+}
+if (!hashFileRange(file, &sigHandler, sigEnd, fileSize)) {
+fclose(file);
+return false;
+}
 
 // and sign it
 const std::unique_ptr signature = 
sigHandler.signDetached(password);
@@ -634,7 +644,9 @@ static char *setNextOffset(char *start, Goffset offset)
 // Returns start/end of signature string and file size.
 bool FormWidgetSignature::updateOffsets(FILE *f, Goffset objStart, Goffset 
objEnd, Goffset *sigStart, Goffset *sigEnd, Goffset *fileSize)
 {
-Gfseek(f, 0, SEEK_END);
+if (Gfseek(f, 0, SEEK_END) != 0) {
+return false;
+}
 *fileSize = Gftell(f);
 
 if (objEnd > *fileSize)
@@ -646,7 +658,9 @@ bool FormWidgetSignature::updateOffsets(FILE *f, Goffset 
objStart, Goffset objEn
 }
 
 int bufSize = static_cast(objEnd - objStart);
-Gfseek(f, objStart, SEEK_SET);
+if (Gfseek(f, objStart, SEEK_SET) != 0) {
+return false;
+}
 std::vector buf(bufSize + 1);
 fread(buf.data(), bufSize, 1, f);
 buf[bufSize] = 0; // prevent string functions from searching past the end
@@ -686,7 +700,9 @@ bool FormWidgetSignature::updateOffsets(FILE *f, Goffset 
objStart, Goffs

[poppler] poppler/Form.cc

2021-01-02 Thread GitLab Mirror
 poppler/Form.cc |6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit 7e4ec140d1cc6bef375e38f3cf3f613dd7c88bbb
Author: Albert Astals Cid 
Date:   Sat Jan 2 23:53:32 2021 +0100

FormWidgetSignature::signDocument: Fix resource leak if something goes wrong

diff --git a/poppler/Form.cc b/poppler/Form.cc
index b1ba7df3..5ee2d514 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -564,6 +564,7 @@ bool FormWidgetSignature::signDocument(const char 
*saveFilename, const char *cer
 FILE *file = openFile(saveFilename, "r+b");
 if (!updateOffsets(file, objStart, objEnd, &sigStart, &sigEnd, &fileSize)) 
{
 fprintf(stderr, "signDocument: unable update byte range\n");
+fclose(file);
 return false;
 }
 
@@ -574,12 +575,15 @@ bool FormWidgetSignature::signDocument(const char 
*saveFilename, const char *cer
 
 // and sign it
 const std::unique_ptr signature = 
sigHandler.signDetached(password);
-if (!signature)
+if (!signature) {
+fclose(file);
 return false;
+}
 
 // write signature to saved file
 if (!updateSignature(file, sigStart, sigEnd, signature.get())) {
 fprintf(stderr, "signDocument: unable update signature\n");
+fclose(file);
 return false;
 }
 signatureField->setSignature(*signature);
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Form.cc

2021-01-02 Thread GitLab Mirror
 poppler/Form.cc |   11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

New commits:
commit 43b5a94a610ce8fbb3d017bcdee85ac8f0be5ea4
Author: Albert Astals Cid 
Date:   Sat Jan 2 23:43:58 2021 +0100

Fix potential memory leak in FormWidgetSignature::updateOffsets

diff --git a/poppler/Form.cc b/poppler/Form.cc
index 2eedbebc..b1ba7df3 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -643,10 +643,8 @@ bool FormWidgetSignature::updateOffsets(FILE *f, Goffset 
objStart, Goffset objEn
 
 int bufSize = static_cast(objEnd - objStart);
 Gfseek(f, objStart, SEEK_SET);
-char *buf = (char *)gmalloc_checkoverflow(bufSize + 1);
-if (!buf)
-return false;
-fread(buf, bufSize, 1, f);
+std::vector buf(bufSize + 1);
+fread(buf.data(), bufSize, 1, f);
 buf[bufSize] = 0; // prevent string functions from searching past the end
 
 // search for the Contents field which contains the signature
@@ -658,7 +656,7 @@ bool FormWidgetSignature::updateOffsets(FILE *f, Goffset 
objStart, Goffset objEn
 *sigStart = objStart + i + 10;
 char *p = strchr(&buf[i], '>');
 if (p)
-*sigEnd = objStart + (p - buf) + 1;
+*sigEnd = objStart + (p - buf.data()) + 1;
 break;
 }
 }
@@ -685,8 +683,7 @@ bool FormWidgetSignature::updateOffsets(FILE *f, Goffset 
objStart, Goffset objEn
 
 // write buffer back to disk
 Gfseek(f, objStart, SEEK_SET);
-fwrite(buf, bufSize, 1, f);
-free(buf);
+fwrite(buf.data(), bufSize, 1, f);
 return true;
 }
 
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] test/goostring-format-checker

2021-01-02 Thread GitLab Mirror
 test/goostring-format-checker/README  |2 +-
 test/goostring-format-checker/goostring-format-checker.cc |3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

New commits:
commit 27258358cd0b82a762382b8f0aafe06abd698484
Author: Albert Astals Cid 
Date:   Sat Jan 2 23:36:06 2021 +0100

clang api changes

diff --git a/test/goostring-format-checker/README 
b/test/goostring-format-checker/README
index cc58a5d7..3be801c8 100644
--- a/test/goostring-format-checker/README
+++ b/test/goostring-format-checker/README
@@ -7,7 +7,7 @@
-Xclang -load -Xclang goostring-format-checker.so -Xclang -plugin 
-Xclang goostring-format-check
 
 Example:
-$ clang++ -shared -o goostring-format-checker.so goostring-format-checker.cc 
-D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
+$ clang++ -fPIC -shared -o goostring-format-checker.so 
goostring-format-checker.cc -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS
 $ export CXX=clang++
 $ export CXXFLAGS="-Xclang -load -Xclang $PWD/goostring-format-checker.so 
-Xclang -add-plugin -Xclang goostring-format-checker"
 $ mkdir build
diff --git a/test/goostring-format-checker/goostring-format-checker.cc 
b/test/goostring-format-checker/goostring-format-checker.cc
index 302772b2..41098561 100644
--- a/test/goostring-format-checker/goostring-format-checker.cc
+++ b/test/goostring-format-checker/goostring-format-checker.cc
@@ -6,6 +6,7 @@
  * Clang++ compiler plugin that checks usage of GooString::format-like 
functions
  *
  * Copyright (C) 2014 Fabio D'Urso 
+ * Copyright (C) 2021 Albert Astals Cid 
  */
 
 #include 
@@ -341,7 +342,7 @@ private:
 class GooStringFormatCheckerAction : public PluginASTAction
 {
 protected:
-ASTConsumer *CreateASTConsumer(CompilerInstance &compInst, llvm::StringRef 
inFile) { return new GooStringFormatCheckerConsumer(&compInst); }
+std::unique_ptr CreateASTConsumer(CompilerInstance &compInst, 
llvm::StringRef inFile) { return 
std::make_unique(&compInst); }
 
 bool ParseArgs(const CompilerInstance &compInst, const 
std::vector &args)
 {
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Form.cc

2021-01-02 Thread GitLab Mirror
 poppler/Form.cc |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit db171f489ca532e48a1c44e2e3dfb9c069754582
Author: Albert Astals Cid 
Date:   Sat Jan 2 23:03:29 2021 +0100

Fix memory leak if saving the file fails

diff --git a/poppler/Form.cc b/poppler/Form.cc
index f75e42f6..2eedbebc 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -5,7 +5,7 @@
 // This file is licensed under the GPLv2 or later
 //
 // Copyright 2006-2008 Julien Rebetez 
-// Copyright 2007-2012, 2015-2020 Albert Astals Cid 
+// Copyright 2007-2012, 2015-2021 Albert Astals Cid 
 // Copyright 2007-2008, 2011 Carlos Garcia Campos 
 // Copyright 2007, 2013, 2016, 2019 Adrian Johnson 
 // Copyright 2007 Iñigo Martínez 
@@ -549,6 +549,7 @@ bool FormWidgetSignature::signDocument(const char 
*saveFilename, const char *cer
 GooString *fname = new GooString(saveFilename);
 if (doc->saveAs(fname, writeForceIncremental) != errNone) {
 fprintf(stderr, "signDocument: error saving to file \"%s\"\n", 
saveFilename);
+delete fname;
 return false;
 }
 
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] poppler/Gfx.cc poppler/Gfx.h

2021-01-02 Thread GitLab Mirror
 poppler/Gfx.cc |   31 ---
 poppler/Gfx.h  |4 ++--
 2 files changed, 14 insertions(+), 21 deletions(-)

New commits:
commit 0a1174ff7043cbdc7195a5df562a96bd0033cb95
Author: Albert Astals Cid 
Date:   Sat Jan 2 22:15:39 2021 +0100

Rework a bit the "infinite" recursion detection of Gfx

Instead of counting drawForm calls, count non toplevel display calls

Remove a check from Gfx::doSoftMask which doesn't seem like it would do
anything, let's hope the automatic fuzzer finds out if it does, git log
says it comes from the xpdf3.02 merge

This fixes issue #1021

diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc
index 78adcf79..20d450ed 100644
--- a/poppler/Gfx.cc
+++ b/poppler/Gfx.cc
@@ -14,7 +14,7 @@
 // under GPL version 2 or later
 //
 // Copyright (C) 2005 Jonathan Blandford 
-// Copyright (C) 2005-2013, 2015-2020 Albert Astals Cid 
+// Copyright (C) 2005-2013, 2015-2021 Albert Astals Cid 
 // Copyright (C) 2006 Thorkild Stray 
 // Copyright (C) 2006 Kristian Høgsberg 
 // Copyright (C) 2006-2011 Carlos Garcia Campos 
@@ -483,7 +483,7 @@ Gfx::Gfx(PDFDoc *docA, OutputDev *outA, int pageNum, Dict 
*resDict, double hDPI,
 for (i = 0; i < 6; ++i) {
 baseMatrix[i] = state->getCTM()[i];
 }
-formDepth = 0;
+displayDepth = 0;
 ocState = true;
 parser = nullptr;
 abortCheckCbk = abortCheckCbkA;
@@ -544,7 +544,7 @@ Gfx::Gfx(PDFDoc *docA, OutputDev *outA, Dict *resDict, 
const PDFRectangle *box,
 for (i = 0; i < 6; ++i) {
 baseMatrix[i] = state->getCTM()[i];
 }
-formDepth = 0;
+displayDepth = 0;
 ocState = true;
 parser = nullptr;
 abortCheckCbk = abortCheckCbkA;
@@ -622,10 +622,13 @@ Gfx::~Gfx()
 
 void Gfx::display(Object *obj, bool topLevel)
 {
-int i;
+// check for excessive recursion
+if (displayDepth > 100) {
+return;
+}
 
 if (obj->isArray()) {
-for (i = 0; i < obj->arrayGetLength(); ++i) {
+for (int i = 0; i < obj->arrayGetLength(); ++i) {
 Object obj2 = obj->arrayGet(i);
 if (!obj2.isStream()) {
 error(errSyntaxError, -1, "Weird page contents");
@@ -1236,11 +1239,6 @@ void Gfx::doSoftMask(Object *str, bool alpha, 
GfxColorSpace *blendingColorSpace,
 Object obj1;
 int i;
 
-// check for excessive recursion
-if (formDepth > 20) {
-return;
-}
-
 // get stream dict
 dict = str->streamGetDict();
 
@@ -1290,9 +1288,7 @@ void Gfx::doSoftMask(Object *str, bool alpha, 
GfxColorSpace *blendingColorSpace,
 resDict = obj1.isDict() ? obj1.getDict() : nullptr;
 
 // draw it
-++formDepth;
 drawForm(str, resDict, m, bbox, true, true, blendingColorSpace, isolated, 
knockout, alpha, transferFunc, backdropColor);
---formDepth;
 }
 
 void Gfx::opSetRenderingIntent(Object args[], int numArgs)
@@ -3920,7 +3916,9 @@ void Gfx::doShowText(const GooString *s)
 }
 }
 if (displayCharProc) {
+++displayDepth;
 display(&charProc, false);
+--displayDepth;
 
 if (refNum != -1) {
 charProcDrawing.erase(charProcDrawingIt);
@@ -4604,11 +4602,6 @@ void Gfx::doForm(Object *str)
 Object obj1;
 int i;
 
-// check for excessive recursion
-if (formDepth > 100) {
-return;
-}
-
 // get stream dict
 dict = str->streamGetDict();
 
@@ -4693,9 +4686,7 @@ void Gfx::doForm(Object *str)
 }
 
 // draw it
-++formDepth;
 drawForm(str, resDict, m, bbox, transpGroup, false, blendingColorSpace, 
isolated, knockout);
---formDepth;
 
 if (blendingColorSpace) {
 delete blendingColorSpace;
@@ -4764,7 +4755,9 @@ void Gfx::drawForm(Object *str, Dict *resDict, const 
double *matrix, const doubl
 GfxState *stateBefore = state;
 
 // draw the form
+++displayDepth;
 display(str, false);
+--displayDepth;
 
 if (stateBefore != state) {
 if (state->isParentState(stateBefore)) {
diff --git a/poppler/Gfx.h b/poppler/Gfx.h
index 808f23c3..3539bd69 100644
--- a/poppler/Gfx.h
+++ b/poppler/Gfx.h
@@ -17,7 +17,7 @@
 // Copyright (C) 2007 Iñigo Martínez 
 // Copyright (C) 2008 Brad Hards 
 // Copyright (C) 2008, 2010 Carlos Garcia Campos 
-// Copyright (C) 2009-2013, 2017, 2018 Albert Astals Cid 
+// Copyright (C) 2009-2013, 2017, 2018, 2021 Albert Astals Cid 
 // Copyright (C) 2009, 2010, 2012, 2013 Thomas Freitag 
 // Copyright (C) 2010 David Benjamin 
 // Copyright (C) 2010 Christian Feuersänger 
@@ -217,7 +217,7 @@ private:
 int ignoreUndef; // current BX/EX nesting level
 double baseMatrix[6]; // default matrix for most recent
   //   page/form/pattern
-int formDepth;
+int displayDepth;
 bool ocState; // true if drawing is enabled, false if
   //   disabled
 
__

[poppler] poppler/JBIG2Stream.cc

2021-01-02 Thread GitLab Mirror
 poppler/JBIG2Stream.cc |   67 -
 1 file changed, 28 insertions(+), 39 deletions(-)

New commits:
commit cc947b5de9fb83d602bd62d74fd691e3581bc47a
Author: Oliver Sander 
Date:   Sat Jan 2 12:21:34 2021 +0100

JBIG2Stream: Don't allocate codeTables on the heap

The codeTables objects are of type std::vector, and therefore
consist of little more than a size and a data pointer.
Allocating them on the stack (i.e., as values) avoids one
indirection, avoids potential memory leaks, and makes the
code easier to read.

diff --git a/poppler/JBIG2Stream.cc b/poppler/JBIG2Stream.cc
index 9eca8d25..a2e4169b 100644
--- a/poppler/JBIG2Stream.cc
+++ b/poppler/JBIG2Stream.cc
@@ -1466,7 +1466,7 @@ bool JBIG2Stream::readSymbolDictSeg(unsigned int segNum, 
unsigned int length, un
 const JBIG2HuffmanTable *huffDHTable, *huffDWTable;
 const JBIG2HuffmanTable *huffBMSizeTable, *huffAggInstTable;
 JBIG2Segment *seg;
-std::vector *codeTables;
+std::vector codeTables;
 JBIG2SymbolDict *inputSymbolDict;
 unsigned int flags, sdTemplate, sdrTemplate, huff, refAgg;
 unsigned int huffDH, huffDW, huffBMSize, huffAggInst;
@@ -1526,7 +1526,6 @@ bool JBIG2Stream::readSymbolDictSeg(unsigned int segNum, 
unsigned int length, un
 }
 
 // get referenced segments: input symbol dictionaries and code tables
-codeTables = new std::vector();
 numInputSyms = 0;
 for (i = 0; i < nRefSegs; ++i) {
 // This is need by bug 12014, returning false makes it not crash
@@ -1537,21 +1536,18 @@ bool JBIG2Stream::readSymbolDictSeg(unsigned int 
segNum, unsigned int length, un
 j = ((JBIG2SymbolDict *)seg)->getSize();
 if (numInputSyms > UINT_MAX - j) {
 error(errSyntaxError, curStr->getPos(), "Too many input 
symbols in JBIG2 symbol dictionary");
-delete codeTables;
 goto eofError;
 }
 numInputSyms += j;
 } else if (seg->getType() == jbig2SegCodeTable) {
-codeTables->push_back(seg);
+codeTables.push_back(seg);
 }
 } else {
-delete codeTables;
 return false;
 }
 }
 if (numInputSyms > UINT_MAX - numNewSyms) {
 error(errSyntaxError, curStr->getPos(), "Too many input symbols in 
JBIG2 symbol dictionary");
-delete codeTables;
 goto eofError;
 }
 
@@ -1574,7 +1570,6 @@ bool JBIG2Stream::readSymbolDictSeg(unsigned int segNum, 
unsigned int length, un
 bitmaps = (JBIG2Bitmap **)gmallocn_checkoverflow(numInputSyms + 
numNewSyms, sizeof(JBIG2Bitmap *));
 if (!bitmaps && (numInputSyms + numNewSyms > 0)) {
 error(errSyntaxError, curStr->getPos(), "Too many input symbols in 
JBIG2 symbol dictionary");
-delete codeTables;
 goto eofError;
 }
 for (i = 0; i < numInputSyms + numNewSyms; ++i) {
@@ -1602,39 +1597,38 @@ bool JBIG2Stream::readSymbolDictSeg(unsigned int 
segNum, unsigned int length, un
 } else if (huffDH == 1) {
 huffDHTable = huffTableE;
 } else {
-if (i >= codeTables->size()) {
+if (i >= codeTables.size()) {
 goto codeTableError;
 }
-huffDHTable = ((JBIG2CodeTable 
*)(*codeTables)[i++])->getHuffTable();
+huffDHTable = ((JBIG2CodeTable *)codeTables[i++])->getHuffTable();
 }
 if (huffDW == 0) {
 huffDWTable = huffTableB;
 } else if (huffDW == 1) {
 huffDWTable = huffTableC;
 } else {
-if (i >= codeTables->size()) {
+if (i >= codeTables.size()) {
 goto codeTableError;
 }
-huffDWTable = ((JBIG2CodeTable 
*)(*codeTables)[i++])->getHuffTable();
+huffDWTable = ((JBIG2CodeTable *)codeTables[i++])->getHuffTable();
 }
 if (huffBMSize == 0) {
 huffBMSizeTable = huffTableA;
 } else {
-if (i >= codeTables->size()) {
+if (i >= codeTables.size()) {
 goto codeTableError;
 }
-huffBMSizeTable = ((JBIG2CodeTable 
*)(*codeTables)[i++])->getHuffTable();
+huffBMSizeTable = ((JBIG2CodeTable 
*)codeTables[i++])->getHuffTable();
 }
 if (huffAggInst == 0) {
 huffAggInstTable = huffTableA;
 } else {
-if (i >= codeTables->size()) {
+if (i >= codeTables.size()) {
 goto codeTableError;
 }
-huffAggInstTable = ((JBIG2CodeTable 
*)(*codeTables)[i++])->getHuffTable();
+huffAggInstTable = ((JBIG2CodeTable 
*)codeTables[i++])->getHuffTable();
 }
 }
-delete codeTables;
 
 // set up the Huffman decoder
 if (huff) {
@@ -1878,7 +1872,6 @@ bool JBIG2Stream::readSymbolDictSeg(unsigned int segNum, 
unsigned int

[poppler] Poppler 21.01.0 released

2021-01-02 Thread Albert Astals Cid
Available from
http://poppler.freedesktop.org/poppler-21.01.0.tar.xz

The tarball is signed at 
http://poppler.freedesktop.org/poppler-21.01.0.tar.xz.sig with my key
http://hkps.pool.sks-keyservers.net/pks/lookup?op=get&search=0xCA262C6C83DE4D2FB28A332A3A6A4DB839EAA6D7

Note: There may be an issue on MSVC, the unofficial appveyor CI is crashing in 
one of the tests https://ci.appveyor.com/project/tsdgeos/poppler-mirror but i 
have not been able to reproduce it locally, more eyes welcome in this regard.

Release 21.01.0
core:
 * Faster routines for jpeg decoding
 * Fix reading signatures in encrypted files
 * Add white point correction when lcms is used
 * JBIG2Stream: Fix byte counting
 * Fix potential data loss if we try to fetch a non existing Ref after 
modifying the document
 * Specifically use DeviceGray instead of DefaultGray for softmasks
 * Fix various issues handling broken files

utils:
 * pdftocairo: Setmode binary for windows
 * pdfsig: Add hability to digitally sign files
 * pdftoppm: add options to set DeviceGray/DeviceRGB/DeviceCMYK
 * pdftops: add options to set DeviceGray/DeviceRGB/DeviceCMYK
 * pdfimages: Account for rotation in PPI calculation

qt5:
 * Add hability to digitally sign files

qt6:
 * Add hability to digitally sign files

build system:
 * Enable clang-tidy bugprone-signed-char-misuse

This release was brought to you by Adam Sampson, Albert Astals Cid, Hans-Ulrich 
Jüttner, Jakub Alba, Katarina Behrens, Lluís Batlle i Rossell, Nelson Benítez 
León, Oliver Sander, Philipp Knechtges, Salvo Miosi, Thomas Freitag, Thorsten 
Behrens, William Bader, mrbax and everyone else that filed bugs or helped with 
code reviews :)

Testing, patches and bug reports welcome.

Cheers,
  Albert


___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] Changes to 'refs/tags/poppler-21.01.0'

2021-01-02 Thread GitLab Mirror
Tag 'poppler-21.01.0' created by Albert Astals Cid  at 
2021-01-02 17:03 +

Poppler 21.01.0

Changes since poppler-20.12.1-90:
---
 0 files changed
---
___
poppler mailing list
poppler@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/poppler


[poppler] CMakeLists.txt cpp/Doxyfile NEWS qt5/src qt6/src

2021-01-02 Thread GitLab Mirror
 CMakeLists.txt |8 
 NEWS   |   26 ++
 cpp/Doxyfile   |2 +-
 qt5/src/CMakeLists.txt |2 +-
 qt5/src/Doxyfile   |2 +-
 qt6/src/CMakeLists.txt |2 +-
 6 files changed, 34 insertions(+), 8 deletions(-)

New commits:
commit 3b82fb789116c805b0a69f6bf3a72466a1e87308
Author: Albert Astals Cid 
Date:   Sat Jan 2 17:54:42 2021 +0100

poppler 21.01.0

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1573249a..cf88eef1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,12 +33,12 @@ if (ECM_FOUND)
 endif()
 endif()
 
-set(POPPLER_MAJOR_VERSION "20")
-set(POPPLER_MINOR_VERSION_STRING "12")
+set(POPPLER_MAJOR_VERSION "21")
+set(POPPLER_MINOR_VERSION_STRING "01")
 # We want the string version to have 08 but the integer version can't have a 
leading 0 since otherwise it's considered octal
 # So strip a leading 0 if found in POPPLER_MINOR_VERSION_STRING and store the 
result in POPPLER_MINOR_VERSION
 string(REGEX REPLACE "^0?(.+)$" "\\1" POPPLER_MINOR_VERSION 
"${POPPLER_MINOR_VERSION_STRING}")
-set(POPPLER_MICRO_VERSION "1")
+set(POPPLER_MICRO_VERSION "0")
 set(POPPLER_VERSION 
"${POPPLER_MAJOR_VERSION}.${POPPLER_MINOR_VERSION_STRING}.${POPPLER_MICRO_VERSION}")
 
 set(CMAKE_CXX_STANDARD 14)
@@ -570,7 +570,7 @@ add_library(poppler STATIC ${poppler_SRCS})
 else()
 add_library(poppler ${poppler_SRCS})
 endif()
-set_target_properties(poppler PROPERTIES VERSION 105.0.0 SOVERSION 105)
+set_target_properties(poppler PROPERTIES VERSION 106.0.0 SOVERSION 106)
 if(MINGW AND BUILD_SHARED_LIBS)
 get_target_property(POPPLER_SOVERSION poppler SOVERSION)
 set_target_properties(poppler PROPERTIES SUFFIX 
"-${POPPLER_SOVERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}")
diff --git a/NEWS b/NEWS
index a2dfab69..39ee7265 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,29 @@
+Release 21.01.0:
+core:
+ * Faster routines for jpeg decoding
+ * Fix reading signatures in encrypted files
+ * Add white point correction when lcms is used
+ * JBIG2Stream: Fix byte counting
+ * Fix potential data loss if we try to fetch a non existing Ref after 
modifying the document
+ * Specifically use DeviceGray instead of DefaultGray for softmasks
+ * Fix various issues handling broken files
+
+utils:
+ * pdftocairo: Setmode binary for windows
+ * pdfsig: Add hability to digitally sign files
+ * pdftoppm: add options to set DeviceGray/DeviceRGB/DeviceCMYK
+ * pdftops: add options to set DeviceGray/DeviceRGB/DeviceCMYK
+ * pdfimages: Account for rotation in PPI calculation
+
+qt5:
+ * Add hability to digitally sign files
+
+qt6:
+ * Add hability to digitally sign files
+
+build system:
+ * Enable clang-tidy bugprone-signed-char-misuse
+
 Release 20.12.1:
 core:
  * PSOutputDev: fixing regression in the rasterization code. Issue 
#1002
diff --git a/cpp/Doxyfile b/cpp/Doxyfile
index e1770c63..498ff0b8 100644
--- a/cpp/Doxyfile
+++ b/cpp/Doxyfile
@@ -31,7 +31,7 @@ PROJECT_NAME   = "Poppler CPP"
 # This could be handy for archiving the generated documentation or
 # if some version control system is used.
 
-PROJECT_NUMBER = 20.12.1
+PROJECT_NUMBER = 21.01.0
 
 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
 # base path where the generated documentation will be put.
diff --git a/qt5/src/CMakeLists.txt b/qt5/src/CMakeLists.txt
index ae055a12..afacd2c3 100644
--- a/qt5/src/CMakeLists.txt
+++ b/qt5/src/CMakeLists.txt
@@ -37,7 +37,7 @@ set(poppler_qt5_SRCS
   poppler-version.cpp
 )
 add_library(poppler-qt5 ${poppler_qt5_SRCS})
-set_target_properties(poppler-qt5 PROPERTIES VERSION 1.26.0 SOVERSION 1)
+set_target_properties(poppler-qt5 PROPERTIES VERSION 1.27.0 SOVERSION 1)
 if(MINGW AND BUILD_SHARED_LIBS)
 get_target_property(POPPLER_QT5_SOVERSION poppler-qt5 SOVERSION)
 set_target_properties(poppler-qt5 PROPERTIES SUFFIX 
"-${POPPLER_QT5_SOVERSION}${CMAKE_SHARED_LIBRARY_SUFFIX}")
diff --git a/qt5/src/Doxyfile b/qt5/src/Doxyfile
index 8677da3e..9f67beec 100644
--- a/qt5/src/Doxyfile
+++ b/qt5/src/Doxyfile
@@ -31,7 +31,7 @@ PROJECT_NAME   = "Poppler Qt5"
 # This could be handy for archiving the generated documentation or
 # if some version control system is used.
 
-PROJECT_NUMBER = 20.12.1
+PROJECT_NUMBER = 21.01.0
 
 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
 # base path where the generated documentation will be put.
diff --git a/qt6/src/CMakeLists.txt b/qt6/src/CMakeLists.txt
index f5042c52..a4cf8323 100644
--- a/qt6/src/CMakeLists.txt
+++ b/qt6/src/CMakeLists.txt
@@ -37,7 +37,7 @@ set(poppler_qt6_SRCS
   poppler-version.cpp
 )
 add_library(poppler-qt6 ${poppler_qt6_SRCS})
-set_target_properties(poppler-qt6 PROPERTIES VERSION 1.0.0 SOVERSION 1)
+set_target_properties(poppler-qt6 PROPERTIES VERSION 1.