From e28a71f2448cd668669fc5c8c06b8e95ff020aff Mon Sep 17 00:00:00 2001 From: Ben Hoyt Date: Thu, 25 Apr 2024 08:41:10 +1200 Subject: [PATCH 1/2] Revert "[Fuzzing] using cifuzz for PR (#154)" This reverts commit bf103d87ba231080cc71056b11bfb6fccd2cbb13. --- .github/workflows/cifuzz.yml | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 .github/workflows/cifuzz.yml diff --git a/.github/workflows/cifuzz.yml b/.github/workflows/cifuzz.yml deleted file mode 100644 index 6cfaf95..0000000 --- a/.github/workflows/cifuzz.yml +++ /dev/null @@ -1,34 +0,0 @@ -name: CIFuzz -on: [pull_request] -permissions: {} -jobs: - Fuzzing: - runs-on: ubuntu-latest - permissions: - security-events: write - steps: - - name: Build Fuzzers - id: build - uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master - with: - oss-fuzz-project-name: 'inih' - - name: Run Fuzzers - uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master - with: - oss-fuzz-project-name: 'inih' - fuzz-seconds: 300 - output-sarif: true - - name: Upload Crash - uses: actions/upload-artifact@v3 - if: failure() && steps.build.outcome == 'success' - with: - name: artifacts - path: ./out/artifacts - - name: Upload Sarif - if: always() && steps.build.outcome == 'success' - uses: github/codeql-action/upload-sarif@v2 - with: - # Path to SARIF file relative to the root of the repository - sarif_file: cifuzz-sarif/results.sarif - checkout_path: cifuzz-sarif - category: CIFuzz From 53a7c0533920e0c3f96d96b837fe3bf1c671dc6a Mon Sep 17 00:00:00 2001 From: Ben Hoyt Date: Thu, 25 Apr 2024 08:44:06 +1200 Subject: [PATCH 2/2] Revert "[oss-fuzz] fuzzing support (#153)" This reverts commit 9114067a92fa58694bd816bb52f805476908a8a2. --- fuzzing/OSS-FUZZ.MD | 31 ------------------------------- fuzzing/inihfuzz.c | 30 ------------------------------ fuzzing/oss-fuzz.sh | 4 ---- 3 files changed, 65 deletions(-) delete mode 100644 fuzzing/OSS-FUZZ.MD delete mode 100755 fuzzing/oss-fuzz.sh diff --git a/fuzzing/OSS-FUZZ.MD b/fuzzing/OSS-FUZZ.MD deleted file mode 100644 index 0824d83..0000000 --- a/fuzzing/OSS-FUZZ.MD +++ /dev/null @@ -1,31 +0,0 @@ -### oss-fuzz local build with ASAN - -``` -export CC=clang -export CFLAGS="-O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=address -fsanitize-address-use-after-scope -fsanitize=fuzzer-no-link" -export LIB_FUZZING_ENGINE="-fsanitize=fuzzer" -``` - -### oss-fuzz local build with MSAN - -``` -export CC=clang -export CFLAGS="-O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=memory -fsanitize-memory-track-origins -fsanitize=fuzzer-no-link" -export LIB_FUZZING_ENGINE="-fsanitize=fuzzer" -``` - - -### oss-fuzz local build with UBSAN -``` -export CC=clang -export CFLAGS="-O1 -fno-omit-frame-pointer -gline-tables-only -DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION -fsanitize=array-bounds,bool,builtin,enum,float-divide-by-zero,function,integer-divide-by-zero,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,unsigned-integer-overflow,unreachable,vla-bound,vptr -fno-sanitize-recover=array-bounds,bool,builtin,enum,float-divide-by-zero,function,integer-divide-by-zero,null,object-size,return,returns-nonnull-attribute,shift,signed-integer-overflow,unreachable,vla-bound,vptr -fsanitize=fuzzer-no-link" -export LIB_FUZZING_ENGINE="-fsanitize=fuzzer" -``` - -### run fuzzer -``` -bash oss-fuzz.sh -mkdir seed/ -cp ../tests/*.ini seed/ -./inihfuzz seed/ -``` diff --git a/fuzzing/inihfuzz.c b/fuzzing/inihfuzz.c index a181152..d07e338 100644 --- a/fuzzing/inihfuzz.c +++ b/fuzzing/inihfuzz.c @@ -41,8 +41,6 @@ void parse(const char* fname) { u++; } -#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - int main(int argc, char **argv) { if (argc < 2) { @@ -52,31 +50,3 @@ int main(int argc, char **argv) parse(argv[1]); return 0; } - -#else - -#define kMinInputLength 20 -#define kMaxInputLength 1024 - -extern int LLVMFuzzerTestOneInput(const char *Data, size_t Size) { - - if (Size < kMinInputLength || Size > kMaxInputLength) { - return 0; - } - - int ret; - *Prev_section = '\0'; - int u = 100; - - char *data = malloc(Size + 1); - memcpy(data, Data, Size); - data[Size] = '\0'; - - ret = ini_parse(data, dumper, &u); - - free(data); - - return ret; -} - -#endif diff --git a/fuzzing/oss-fuzz.sh b/fuzzing/oss-fuzz.sh deleted file mode 100755 index e92ff37..0000000 --- a/fuzzing/oss-fuzz.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash -$CC $CFLAGS -c ../ini.c -$CC $CFLAGS -c inihfuzz.c -$CXX $CFLAGS $LIB_FUZZING_ENGINE inihfuzz.o ini.o -o inihfuzz