[poppler] qt5/tests

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Jan 3 00:47:35 UTC 2021


 qt5/tests/fuzzing/qt_pdf_fuzzer.cc |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

New commits:
commit bae34cd97a94ff9aa7ad9458f04e494451828b0d
Author: Albert Astals Cid <aacid at kde.org>
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 <cstdint>
 #include <poppler-qt5.h>
+#include <QtCore/QBuffer>
 #include <QtGui/QImage>
 
 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<int> 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;
 }


More information about the poppler mailing list