summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Löhning <robert.loehning@qt.io>2022-05-13 22:15:42 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-05-25 10:16:10 +0000
commit23a77711f052c023627dbc65b96801e8923ab2cf (patch)
tree1069ac94f15bd5ced2636a4caae35964a741c47f
parente46b3dc574bdf51e1e5bf01444780b0c25ba0b85 (diff)
Add finding from oss-fuzz to tst_qicns
Task-number: QTBUG-103454 Change-Id: I86bf891e67bcd483ed0b551190244b94677d1751 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> (cherry picked from commit a678f3df9d644ca054aea33e8b3e7e40ce300558) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--tests/auto/icns/tst_qicns.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/auto/icns/tst_qicns.cpp b/tests/auto/icns/tst_qicns.cpp
index a9e8016..99f0cf5 100644
--- a/tests/auto/icns/tst_qicns.cpp
+++ b/tests/auto/icns/tst_qicns.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2022 The Qt Company Ltd.
** Copyright (C) 2016 Alex Char.
** Contact: https://www.qt.io/licensing/
**
@@ -40,6 +40,8 @@ private slots:
void readIcons();
void writeIcons_data();
void writeIcons();
+ void ossFuzz_data();
+ void ossFuzz();
};
void tst_qicns::initTestCase()
@@ -120,5 +122,25 @@ void tst_qicns::writeIcons()
QVERIFY(image == QImage(distPath));
}
+void tst_qicns::ossFuzz_data()
+{
+ QTest::addColumn<QByteArray>("data");
+ QTest::addColumn<QByteArrayList>("ignoredMessages");
+ QTest::newRow("47415") << QByteArray::fromRawData("icns\0\0\0\0", 8)
+ << QByteArrayList({"QICNSHandler::scanDevice(): Failed, bad header at "
+ "pos 8. OSType \"icns\", length 0",
+ "QICNSHandler::read(): The device wasn't parsed "
+ "properly!"});
+}
+
+void tst_qicns::ossFuzz()
+{
+ QFETCH(QByteArray, data);
+ QFETCH(QByteArrayList, ignoredMessages);
+ for (auto msg: ignoredMessages)
+ QTest::ignoreMessage(QtWarningMsg, msg.data());
+ QImage().loadFromData(data);
+}
+
QTEST_MAIN(tst_qicns)
#include "tst_qicns.moc"