Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit d2d1b578 authored by Leslie Zhai's avatar Leslie Zhai

Update fuzzer testcase for QFile and QString.

CCBUG: 386983
parent 5a0d015c
......@@ -314,7 +314,7 @@ if(BUILD_TESTING)
PURPOSE "libFuzzer – a library for coverage-guided fuzz testing."
URL "http://libfuzzer.info"
TYPE OPTIONAL)
add_subdirectory( tests )
add_subdirectory(tests)
endif()
################### K3b config summary ################################
......
......@@ -47,10 +47,11 @@ For debug:
-DK3B_ENABLE_PERMISSION_HELPER=ON \
-DK3B_DEBUG=ON
dynamic analyzer:
dynamic analyzer and fuzzer:
cmake .. -DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_CXX_COMPILER=clang++ \
-DECM_ENABLE_SANITIZERS='address;undefined' \
-DCMAKE_CXX_FLAGS="-fsanitize-coverage=edge,indirect-calls,8bit-counters,trace-bb,trace-cmp" \
-DCMAKE_BUILD_TYPE=Debug \
-DKDE_INSTALL_LIBDIR=lib \
-DKDE_INSTALL_LIBEXECDIR=lib \
......
......@@ -90,12 +90,11 @@ target_link_libraries(k3bexternalbinmanagertest
add_test(k3bexternalbinmanagertest k3bexternalbinmanagertest)
if(LIBFUZZER_FOUND)
find_package(Threads)
add_executable(k3bfuzzertest
k3bfuzzertest.cpp
${CMAKE_SOURCE_DIR}/libk3b/tools/libisofs/isofs.cpp)
target_include_directories(k3bfuzzertest PRIVATE
${CMAKE_SOURCE_DIR}/libk3b)
k3bfuzzertest.cpp)
target_link_libraries(k3bfuzzertest
Qt5::Core
${LIBFUZZER_LIBRARIES})
${LIBFUZZER_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT})
endif()
#include <QDebug>
/*
* Copyright (C) 2016 - 2017 Leslie Zhai <lesliezhai@llvm.org.cn>
*
* This file is part of the K3b project.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
* See the file "COPYING" for the exact licensing terms.
*/
#include "tools/libisofs/isofs.h"
#include <QDebug>
#include <QFile>
#include <QString>
extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
{
......@@ -11,10 +23,8 @@ extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size)
{
char *d = (char *)malloc(1024);
memset(d, 0, 1024);
strncpy(d, "hello", 5);
str_nappend(&d, (char *)Data, Size);
free(d);
// QTBUG-57553
qDebug() << "DEBUG:" << __PRETTY_FUNCTION__
<< QFile::encodeName(QString::fromRawData((const QChar *)Data, Size));
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment