Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into msan
Browse files Browse the repository at this point in the history
  • Loading branch information
maflcko committed May 2, 2024
2 parents f77f67f + 38cc0c4 commit 02f109b
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 17 deletions.
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ authors:
affiliation: Google LLC
orcid: 'https://orcid.org/0009-0006-3181-4551'
- given-names: Jonathan
family-names: metzman
family-names: Metzman
email: [email protected]
affiliation: Google LLC
orcid: 'https://orcid.org/0000-0002-7042-0444'
Expand Down
5 changes: 4 additions & 1 deletion projects/bitcoin-core/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
#
################################################################################

$SRC/build_cryptofuzz.sh
if [ "$SANITIZER" != "introspector" ]; then
# Temporarily skip this under introspector
$SRC/build_cryptofuzz.sh
fi

cd $SRC/bitcoin-core/

Expand Down
2 changes: 1 addition & 1 deletion projects/bitcoin-core/project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ architectures:
- x86_64
- i386
fuzzing_engines:
- centipede
- libfuzzer
- honggfuzz
- afl
# - centipede # temporarily disabled due to spurious "Step #22 - "build-check-centipede-none-x86_64": OSError: [Errno 28] No space left on device"
5 changes: 3 additions & 2 deletions projects/inih/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
################################################################################
FROM gcr.io/oss-fuzz-base/base-builder
RUN apt-get update
RUN git clone https://github.com/benhoyt/inih
COPY build.sh $SRC/
RUN git clone https://github.com/benhoyt/inih.git
COPY inihfuzz.c $SRC/inih/inihfuzz.c
COPY build.sh $SRC/build.sh
WORKDIR $SRC/inih/
13 changes: 8 additions & 5 deletions projects/inih/build.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash -eu
# Copyright 2023 Google LLC
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -14,10 +14,13 @@
# limitations under the License.
#
################################################################################
pushd fuzzing/
bash oss-fuzz.sh
cp inihfuzz $OUT/
popd

# Compile the fuzzer binary for oss-fuzz infrastructure.
$CC $CFLAGS -c ini.c
$CC $CFLAGS -c inihfuzz.c
$CXX $CFLAGS $LIB_FUZZING_ENGINE inihfuzz.o ini.o -o inihfuzz

# Setup for oss-fuzz infrastructure.
cp inihfuzz $OUT/
zip -r inihfuzz_seed_corpus.zip tests/*.ini
mv inihfuzz_seed_corpus.zip $OUT/
59 changes: 59 additions & 0 deletions projects/inih/inihfuzz.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright 2024 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ini.h"

#define kMinInputLength 8
#define kMaxInputLength 512

int User;
char Prev_section[50];

int dumper(void* user, const char* section, const char* name,
const char* value)
{
User = *((int*)user);
if (strcmp(section, Prev_section)) {
strncpy(Prev_section, section, sizeof(Prev_section));
Prev_section[sizeof(Prev_section) - 1] = '\0';
}
return 1;
}

extern int LLVMFuzzerTestOneInput(const char *data, size_t size) {
if (size < kMinInputLength || size > kMaxInputLength) {
return 0;
}

int e;
static int u = 100;
Prev_section[0] = '\0';

char *data_in = malloc(size + 1);
if (!data_in) return 0; // Just in case malloc fails

memcpy(data_in, data, size);
data_in[size] = '\0';

e = ini_parse_string(data_in, dumper, &u);

free(data_in);

return e;
}
2 changes: 1 addition & 1 deletion projects/inih/project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ homepage: "https://github.com/benhoyt/inih"
language: c
primary_contact: "[email protected]"
auto_ccs:
- "ajsinghyadav00@gmail.com"
- "pkillarjun@protonmail.com"
fuzzing_engines:
- libfuzzer
- afl
Expand Down
3 changes: 1 addition & 2 deletions projects/leveldb/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
#
################################################################################

FROM gcr.io/oss-fuzz-base/base-builder@sha256:19782f7fe8092843368894dbc471ce9b30dd6a2813946071a36e8b05f5b1e27e
# ! This project was pinned after a clang bump. Please remove the pin, Try to fix any build warnings and errors, as well as runtime errors
FROM gcr.io/oss-fuzz-base/base-builder
RUN apt-get update && apt-get install -y build-essential cmake gettext make
RUN git clone --recurse-submodules https://github.com/google/leveldb.git

Expand Down
4 changes: 4 additions & 0 deletions projects/leveldb/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
#
################################################################################

# Avoid: clang++: error: invalid argument '-fsanitize=vptr' not allowed with '-fno-rtti'
CFLAGS="$CFLAGS -fno-sanitize=vptr"
CXXFLAGS="$CXXFLAGS -fno-sanitize=vptr"

cd $SRC/leveldb
mkdir -p build && cd build
cmake -DCMAKE_BUILD_TYPE=Release -DLEVELDB_BUILD_TESTS=0 \
Expand Down
3 changes: 1 addition & 2 deletions projects/msquic/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
#
################################################################################

FROM gcr.io/oss-fuzz-base/base-builder@sha256:19782f7fe8092843368894dbc471ce9b30dd6a2813946071a36e8b05f5b1e27e
# ! This project was pinned after a clang bump. Please remove the pin, Try to fix any build warnings and errors, as well as runtime errors
FROM gcr.io/oss-fuzz-base/base-builder

ADD https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb packages-microsoft-prod.deb
RUN apt-get update && \
Expand Down
4 changes: 4 additions & 0 deletions projects/msquic/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#
################################################################################

# Temporary workaround for clang-18
export CFLAGS="$CFLAGS -Wno-error=invalid-unevaluated-string"
export CXXFLAGS="$CXXFLAGS -Wno-error=invalid-unevaluated-string"

pwsh ./scripts/build.ps1 -Static -DisableTest -DisablePerf -DisableLogs -Parallel 1

cd $SRC/msquic/src/fuzzing
Expand Down
3 changes: 1 addition & 2 deletions projects/serenity/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
#
################################################################################

FROM gcr.io/oss-fuzz-base/base-builder@sha256:19782f7fe8092843368894dbc471ce9b30dd6a2813946071a36e8b05f5b1e27e
# ! This project was pinned after a clang bump. Please remove the pin, Try to fix any build warnings and errors, as well as runtime errors
FROM gcr.io/oss-fuzz-base/base-builder
RUN apt-get update && apt-get install -y build-essential cmake curl ninja-build
RUN git clone https://github.com/SerenityOS/serenity
COPY build.sh $SRC/
Expand Down

0 comments on commit 02f109b

Please sign in to comment.