mirror of
https://github.com/LongSoft/UEFITool.git
synced 2024-11-24 17:08:23 +08:00
Add minimal libFuzzer-compatible harness for FfsParser
This commit is contained in:
parent
69edce7d77
commit
209fbb6282
16
.github/workflows/main.yml
vendored
16
.github/workflows/main.yml
vendored
@ -185,20 +185,20 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
UEFITOOL_VER=$(cat ../../../UEFITool/version.h | grep PROGRAM_VERSION | cut -d'"' -f2 | sed 's/NE alpha /A/') ; \
|
UEFITOOL_VER=$(cat ../../../UEFITool/version.h | grep PROGRAM_VERSION | cut -d'"' -f2 | sed 's/NE alpha /A/') ; \
|
||||||
7z a ../../../UEFITool/dist/UEFIFind_NE_${UEFITOOL_VER}_win32.zip UEFIFind.exe
|
7z a ../../../UEFITool/dist/UEFIFind_NE_${UEFITOOL_VER}_win32.zip UEFIFind.exe
|
||||||
- name: Create UEFITool win32 build directory
|
- name: Create UEFITool build directory
|
||||||
run: cmake -E make_directory ${{runner.workspace}}/build/UEFITool_win32
|
run: cmake -E make_directory ${{runner.workspace}}/build/UEFITool
|
||||||
- name: Configure UEFITool win32
|
- name: Configure UEFITool
|
||||||
shell: bash
|
shell: bash
|
||||||
working-directory: ${{runner.workspace}}/build/UEFITool_win32
|
working-directory: ${{runner.workspace}}/build/UEFITool
|
||||||
run: ../../qt-5.6.3-static-x86-msvc2017/bin/qmake.exe -tp vc ../../UEFITool/UEFITool/
|
run: ../../qt-5.6.3-static-x86-msvc2017/bin/qmake.exe -tp vc ../../UEFITool/UEFITool/
|
||||||
- name: Build UEFITool win32
|
- name: Build UEFITool
|
||||||
working-directory: ${{runner.workspace}}/build/UEFITool_win32
|
working-directory: ${{runner.workspace}}/build/UEFITool
|
||||||
shell: cmd
|
shell: cmd
|
||||||
run: |
|
run: |
|
||||||
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars32.bat"
|
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars32.bat"
|
||||||
msbuild -t:Rebuild -p:PlatformToolset=v141_xp;Configuration=Release
|
msbuild -t:Rebuild -p:PlatformToolset=v141_xp;Configuration=Release
|
||||||
- name: Archive UEFITool win32
|
- name: Archive UEFITool
|
||||||
working-directory: ${{runner.workspace}}/build/UEFITool_win32/release
|
working-directory: ${{runner.workspace}}/build/UEFITool/release
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
UEFITOOL_VER=$(cat ../../../UEFITool/version.h | grep PROGRAM_VERSION | cut -d'"' -f2 | sed 's/NE alpha /A/') ; \
|
UEFITOOL_VER=$(cat ../../../UEFITool/version.h | grep PROGRAM_VERSION | cut -d'"' -f2 | sed 's/NE alpha /A/') ; \
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* fssfinder.cpp
|
/* ffsfinder.cpp
|
||||||
|
|
||||||
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
|
Copyright (c) 2015, Nikolaj Schlej. All rights reserved.
|
||||||
This program and the accompanying materials
|
This program and the accompanying materials
|
||||||
|
65
fuzzing/CMakeLists.txt
Normal file
65
fuzzing/CMakeLists.txt
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
CMAKE_MINIMUM_REQUIRED(VERSION 3.1.0 FATAL_ERROR)
|
||||||
|
|
||||||
|
PROJECT(ffsparser_fuzzer)
|
||||||
|
|
||||||
|
SET(CMAKE_CXX_STANDARD 11)
|
||||||
|
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
SET(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
|
SET(PROJECT_SOURCES
|
||||||
|
ffsparser_fuzzer.cpp
|
||||||
|
../common/types.cpp
|
||||||
|
../common/descriptor.cpp
|
||||||
|
../common/guiddatabase.cpp
|
||||||
|
../common/ffs.cpp
|
||||||
|
../common/nvram.cpp
|
||||||
|
../common/nvramparser.cpp
|
||||||
|
../common/ffsparser.cpp
|
||||||
|
../common/fitparser.cpp
|
||||||
|
../common/peimage.cpp
|
||||||
|
../common/treeitem.cpp
|
||||||
|
../common/treemodel.cpp
|
||||||
|
../common/utility.cpp
|
||||||
|
../common/LZMA/LzmaDecompress.c
|
||||||
|
../common/LZMA/SDK/C/Bra.c
|
||||||
|
../common/LZMA/SDK/C/Bra86.c
|
||||||
|
../common/LZMA/SDK/C/CpuArch.c
|
||||||
|
../common/LZMA/SDK/C/LzmaDec.c
|
||||||
|
../common/Tiano/EfiTianoDecompress.c
|
||||||
|
../common/ustring.cpp
|
||||||
|
../common/bstrlib/bstrlib.c
|
||||||
|
../common/bstrlib/bstrwrap.cpp
|
||||||
|
../common/generated/intel_acbp_v1.cpp
|
||||||
|
../common/generated/intel_acbp_v2.cpp
|
||||||
|
../common/generated/intel_keym_v1.cpp
|
||||||
|
../common/generated/intel_keym_v2.cpp
|
||||||
|
../common/generated/intel_acm.cpp
|
||||||
|
../common/kaitai/kaitaistream.cpp
|
||||||
|
../common/digest/sha1.c
|
||||||
|
../common/digest/sha256.c
|
||||||
|
../common/digest/sha512.c
|
||||||
|
../common/digest/sm3.c
|
||||||
|
../common/zlib/adler32.c
|
||||||
|
../common/zlib/compress.c
|
||||||
|
../common/zlib/crc32.c
|
||||||
|
../common/zlib/deflate.c
|
||||||
|
../common/zlib/gzclose.c
|
||||||
|
../common/zlib/gzlib.c
|
||||||
|
../common/zlib/gzread.c
|
||||||
|
../common/zlib/gzwrite.c
|
||||||
|
../common/zlib/inflate.c
|
||||||
|
../common/zlib/infback.c
|
||||||
|
../common/zlib/inftrees.c
|
||||||
|
../common/zlib/inffast.c
|
||||||
|
../common/zlib/trees.c
|
||||||
|
../common/zlib/uncompr.c
|
||||||
|
../common/zlib/zutil.c
|
||||||
|
)
|
||||||
|
|
||||||
|
ADD_DEFINITIONS(-DU_ENABLE_NVRAM_PARSING_SUPPORT -DU_ENABLE_FIT_PARSING_SUPPORT)
|
||||||
|
|
||||||
|
ADD_EXECUTABLE(ffsparser_fuzzer ${PROJECT_SOURCES})
|
||||||
|
|
||||||
|
TARGET_COMPILE_OPTIONS(ffsparser_fuzzer PRIVATE -g -O1 -fsanitize=fuzzer)
|
||||||
|
|
||||||
|
TARGET_LINK_LIBRARIES(ffsparser_fuzzer PRIVATE -fsanitize=fuzzer)
|
31
fuzzing/ffsparser_fuzzer.cpp
Normal file
31
fuzzing/ffsparser_fuzzer.cpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/* ffsparser_fuzzer.cpp
|
||||||
|
|
||||||
|
Copyright (c) 2023, Nikolaj Schlej. All rights reserved.
|
||||||
|
This program and the accompanying materials
|
||||||
|
are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
which accompanies this distribution. The full text of the license may be found at
|
||||||
|
http://opensource.org/licenses/bsd-license.php
|
||||||
|
|
||||||
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../common/ffsparser.h"
|
||||||
|
|
||||||
|
#define FUZZING_MIN_INPUT_SIZE 16
|
||||||
|
#define FUZZING_MAX_INPUT_SIZE (128 * 1024 * 1024)
|
||||||
|
|
||||||
|
extern "C" int LLVMFuzzerTestOneInput(const char *Data, long long Size) {
|
||||||
|
// Do not overblow the inout file size, won't change much in practical sense
|
||||||
|
if (Size > FUZZING_MAX_INPUT_SIZE || Size < FUZZING_MIN_INPUT_SIZE) return 0;
|
||||||
|
|
||||||
|
// Create the FFS parser
|
||||||
|
TreeModel* model = new TreeModel();
|
||||||
|
FfsParser* ffsParser = new FfsParser(model);
|
||||||
|
|
||||||
|
// Parse the image
|
||||||
|
(void)ffsParser->parse(UByteArray(Data, (uint32_t)Size));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user