Skip to content

Commit

Permalink
Revert "These two benchmarks failed on coverage report generation."
Browse files Browse the repository at this point in the history
This reverts commit 50bdf34.
  • Loading branch information
DonggeLiu committed Aug 14, 2024
1 parent 50bdf34 commit e4a52c8
Show file tree
Hide file tree
Showing 30 changed files with 253 additions and 0 deletions.
29 changes: 29 additions & 0 deletions benchmarks/openh264_decoder_fuzzer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright 2018 Google Inc.
#
# 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.
#
################################################################################

FROM gcr.io/oss-fuzz-base/base-builder@sha256:87ca1e9e19235e731fac8de8d1892ebe8d55caf18e7aa131346fc582a2034fdd
MAINTAINER twsmith@mozilla.com

RUN dpkg --add-architecture i386 && \
apt-get update && \
apt-get install -y \
libstdc++-9-dev libstdc++-9-dev:i386 nasm subversion

RUN git clone \
https://github.com/cisco/openh264.git

WORKDIR openh264
COPY build.sh decoder_fuzzer.cpp $SRC/
23 changes: 23 additions & 0 deletions benchmarks/openh264_decoder_fuzzer/benchmark.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
commit: 045aeac1dd01df12dec7b1ef8191b3193cf4273c
commit_date: 2023-01-04T08:01:08+00:00
fuzz_target: decoder_fuzzer
project: openh264
unsupported_fuzzers:
- aflcc
- afl_qemu
- aflplusplus_qemu
- aflplusplus_qemu_tracepc
- aflplusplus_frida
- honggfuzz_qemu
- klee
- lafintel
- weizz_qemu
- aflplusplus_cmplog_double
- symcc_aflplusplus_single
- eclipser_aflplusplus
- aflplusplus_qemu_double
- fuzzolic_aflplusplus_z3
- symqemu_aflplusplus
- fuzzolic_aflplusplus_fuzzy
- fuzzolic_aflplusplus_z3dict
- tortoisefuzz
25 changes: 25 additions & 0 deletions benchmarks/openh264_decoder_fuzzer/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash -eu
# Copyright 2018 Google Inc.
#
# 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.
#
################################################################################

# build
if [[ $CXXFLAGS = *sanitize=memory* ]]; then
ASM_BUILD=No
else
ASM_BUILD=Yes
fi
make -j$(nproc) ARCH=$ARCHITECTURE USE_ASM=$ASM_BUILD BUILDTYPE=Debug libraries
$CXX $CXXFLAGS -o $OUT/decoder_fuzzer -I./codec/api/wels -I./codec/console/common/inc -I./codec/common/inc -L. $LIB_FUZZING_ENGINE $SRC/decoder_fuzzer.cpp libopenh264.a
84 changes: 84 additions & 0 deletions benchmarks/openh264_decoder_fuzzer/decoder_fuzzer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// TODO: This should be moved to the openh264 repo.

#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <memory>

#include "codec_def.h"
#include "codec_app_def.h"
#include "codec_api.h"
#include "read_config.h"
#include "typedefs.h"
#include "measure_time.h"

/*
* To build locally:
* CC=clang CXX=clang++ CFLAGS="-fsanitize=address,fuzzer-no-link -g" CXXFLAGS="-fsanitize=address,fuzzer-no-link -g" LDFLAGS="-fsanitize=address,fuzzer-no-link" make -j$(nproc) USE_ASM=No BUILDTYPE=Debug libraries
* clang++ -o decoder_fuzzer -fsanitize=address -g -O1 -I./codec/api/svc -I./codec/console/common/inc -I./codec/common/inc -L. -lFuzzer -lstdc++ decoder_fuzzer.cpp libopenh264.a
*/

extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
{
int32_t i;
int32_t iBufPos = 0;
int32_t iEndOfStreamFlag;
int iLevelSetting = (int) WELS_LOG_QUIET; // disable logging while fuzzing
int32_t iSliceSize;
ISVCDecoder *pDecoder;
SDecodingParam sDecParam = {0};
SBufferInfo sDstBufInfo;
std::unique_ptr<uint8_t[]> pBuf(new uint8_t[size + 4]);
uint8_t* pData[3] = {NULL};
uint8_t uiStartCode[4] = {0, 0, 0, 1};

memcpy(pBuf.get(), data, size);
memcpy(pBuf.get() + size, &uiStartCode[0], 4);
memset(&sDstBufInfo, 0, sizeof(SBufferInfo));

// TODO: is this the best/fastest ERROR_CON to use?
sDecParam.eEcActiveIdc = ERROR_CON_SLICE_COPY;
// TODO: should we also fuzz VIDEO_BITSTREAM_SVC?
sDecParam.sVideoProperty.eVideoBsType = VIDEO_BITSTREAM_AVC;

WelsCreateDecoder (&pDecoder);
pDecoder->Initialize (&sDecParam);
pDecoder->SetOption (DECODER_OPTION_TRACE_LEVEL, &iLevelSetting);

while (1) {
if (iBufPos >= size) {
iEndOfStreamFlag = 1;
if (iEndOfStreamFlag)
pDecoder->SetOption (DECODER_OPTION_END_OF_STREAM, (void*)&iEndOfStreamFlag);
break;
}

for (i = 0; i < size; i++) {
if ((pBuf[iBufPos + i] == 0 && pBuf[iBufPos + i + 1] == 0 && pBuf[iBufPos + i + 2] == 0 && pBuf[iBufPos + i + 3] == 1
&& i > 0) || (pBuf[iBufPos + i] == 0 && pBuf[iBufPos + i + 1] == 0 && pBuf[iBufPos + i + 2] == 1 && i > 0)) {
break;
}
}
iSliceSize = i;
if (iSliceSize < 4) {
if (iSliceSize == 0) {
// I don't think this should happen but let's just avoid the hang
goto label_cleanup;
}
iBufPos += iSliceSize;
continue;
}

pDecoder->DecodeFrameNoDelay (pBuf.get() + iBufPos, iSliceSize, pData, &sDstBufInfo);
iBufPos += iSliceSize;
}

label_cleanup:
pDecoder->Uninitialize ();
WelsDestroyDecoder (pDecoder);

return 0;
}
Binary file added benchmarks/openh264_decoder_fuzzer/testcases/18438
Binary file not shown.
Binary file not shown.
Binary file added benchmarks/openh264_decoder_fuzzer/testcases/18459
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added benchmarks/openh264_decoder_fuzzer/testcases/18644
Binary file not shown.
Binary file added benchmarks/openh264_decoder_fuzzer/testcases/18743
Binary file not shown.
50 changes: 50 additions & 0 deletions benchmarks/stb_stbi_read_fuzzer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Copyright 2020 Google Inc.
#
# 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.
#
################################################################################

FROM gcr.io/oss-fuzz-base/base-builder@sha256:87ca1e9e19235e731fac8de8d1892ebe8d55caf18e7aa131346fc582a2034fdd

RUN apt-get update && \
apt-get install -y \
wget tar

# This project does not have any release/tag.
RUN git clone \
https://github.com/nothings/stb.git

RUN mkdir $SRC/stbi # CIFuzz workaround

RUN wget -O \
$SRC/stbi/gif.tar.gz https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/imagetestsuite/imagetestsuite-gif-1.00.tar.gz
RUN wget -O \
$SRC/stbi/jpg.tar.gz https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/imagetestsuite/imagetestsuite-jpg-1.00.tar.gz
RUN wget -O \
$SRC/stbi/bmp.zip http://entropymine.com/jason/bmpsuite/releases/bmpsuite-2.6.zip
RUN wget -O \
$SRC/stbi/tga.zip https://github.com/richgel999/tga_test_files/archive/master.zip

RUN wget -O \
$SRC/stbi/gif.dict https://raw.githubusercontent.com/mirrorer/afl/master/dictionaries/gif.dict

# Maintain compatibility with master branch until a new release
RUN cp \
$SRC/stbi/gif.tar.gz \
$SRC/stbi/jpg.tar.gz \
$SRC/stbi/bmp.zip \
$SRC/stbi/gif.dict \
$SRC/stb

WORKDIR stb
COPY build.sh $SRC/
23 changes: 23 additions & 0 deletions benchmarks/stb_stbi_read_fuzzer/benchmark.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
commit: 5736b15f7ea0ffb08dd38af21067c314d6a3aae9
commit_date: 2023-01-29T18:46:04+00:00
fuzz_target: stbi_read_fuzzer
project: stb
oss_fuzz_corpus_target: stb_stbi_read_fuzzer
unsupported_fuzzers:
- aflcc
- afl_qemu
- aflplusplus_qemu
- aflplusplus_qemu_tracepc
- aflplusplus_frida
- honggfuzz_qemu
- klee
- lafintel
- weizz_qemu
- aflplusplus_cmplog_double
- symcc_aflplusplus_single
- eclipser_aflplusplus
- aflplusplus_qemu_double
- fuzzolic_aflplusplus_z3
- symqemu_aflplusplus
- fuzzolic_aflplusplus_fuzzy
- fuzzolic_aflplusplus_z3dict
18 changes: 18 additions & 0 deletions benchmarks/stb_stbi_read_fuzzer/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash -eu
# Copyright 2020 Google Inc.
#
# 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.
#
################################################################################
# Run the OSS-Fuzz script in the project
$SRC/stb/tests/ossfuzz.sh
Binary file added benchmarks/stb_stbi_read_fuzzer/testcases/22580
Binary file not shown.
Binary file added benchmarks/stb_stbi_read_fuzzer/testcases/22584
Binary file not shown.
Binary file added benchmarks/stb_stbi_read_fuzzer/testcases/22587
Binary file not shown.
Binary file added benchmarks/stb_stbi_read_fuzzer/testcases/22596
Binary file not shown.
Binary file added benchmarks/stb_stbi_read_fuzzer/testcases/22605
Binary file not shown.
1 change: 1 addition & 0 deletions benchmarks/stb_stbi_read_fuzzer/testcases/22620
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
P63333333333
Binary file added benchmarks/stb_stbi_read_fuzzer/testcases/22640
Binary file not shown.
Binary file added benchmarks/stb_stbi_read_fuzzer/testcases/22648
Binary file not shown.
Binary file added benchmarks/stb_stbi_read_fuzzer/testcases/22651
Binary file not shown.
Binary file added benchmarks/stb_stbi_read_fuzzer/testcases/23153
Binary file not shown.
Binary file added benchmarks/stb_stbi_read_fuzzer/testcases/24185
Binary file not shown.

0 comments on commit e4a52c8

Please sign in to comment.