File indexing completed on 2022-10-04 15:34:12

0001 /*
0002     SPDX-FileCopyrightText: 2016-2017 Leslie Zhai <lesliezhai@llvm.org.cn>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 
0006 #include <QDebug>
0007 #include <QFile>
0008 #include <QString>
0009 
0010 extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) 
0011 {
0012     qDebug() << "DEBUG:" << __PRETTY_FUNCTION__ << *argc;
0013     qDebug() << "DEBUG:" << __PRETTY_FUNCTION__ << *argv[0];
0014     return 0;
0015 }
0016 
0017 extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) 
0018 {
0019     // QTBUG-57553, KDEBUG-391610
0020     qDebug() << "DEBUG:" << __PRETTY_FUNCTION__
0021              << QFile::encodeName(QString::fromRawData((const QChar *)Data, Size));
0022     // KDEBUG-384750
0023     QStringList lines("xorriso : UPDATE :  0,52\% done, estimate finish Mon Sep 25 11:04:34 2017");
0024     lines << "xorriso : UPDATE :  0.52\% done, estimate finish Mon Sep 25 11:04:34 2017";
0025     lines << "0.52\% done, estimate finish Mon Sep 25 11:04:34 2017";
0026     for (QString line : lines) {
0027         QString perStr = line;
0028         perStr.truncate(perStr.indexOf('%'));
0029         QRegExp rx("(\\d+.|,+\\d)");
0030         QStringList list;
0031         int pos = 0;
0032         while ((pos = rx.indexIn(perStr, pos)) != -1) {
0033             list << rx.cap(1);
0034             pos += rx.matchedLength();
0035         }
0036         if (list.size() > 1)
0037             qDebug() << "DEBUG:" << __PRETTY_FUNCTION__ << list[0].replace(',', '.') + list[1];
0038     }
0039     return 0;
0040 }