diff --git a/projects/astc-encoder/Dockerfile b/projects/astc-encoder/Dockerfile index 9e3b58e24..3872f223e 100644 --- a/projects/astc-encoder/Dockerfile +++ b/projects/astc-encoder/Dockerfile @@ -18,5 +18,4 @@ FROM gcr.io/oss-fuzz-base/base-builder RUN apt-get update && apt-get install -y make autoconf automake libtool RUN git clone --depth 1 https://github.com/ARM-software/astc-encoder WORKDIR astc-encoder/Source -COPY build.sh *_fuzzer.cc $SRC/ -COPY Makefile.patch $SRC/astc-encoder/Source +COPY build.sh $SRC/ diff --git a/projects/astc-encoder/Makefile.patch b/projects/astc-encoder/Makefile.patch deleted file mode 100644 index a210aba98..000000000 --- a/projects/astc-encoder/Makefile.patch +++ /dev/null @@ -1,27 +0,0 @@ -diff --git a/Source/Makefile b/Source/Makefile -index 459ec42..52fc8c9 100644 ---- a/Source/Makefile -+++ b/Source/Makefile -@@ -92,21 +92,21 @@ HEADERS = \ - - BINARY = $(APP)-$(VEC) - - OBJECTS = $(SOURCES:.cpp=-$(BINARY).o) - - EXTERNAL_OBJECTS = $(EXTERNAL_SOURCES:.h=-$(BINARY).o) - - # ================================================== - # CXXFLAGS setup (and input validation) - --CXXFLAGS = -std=c++14 -fvisibility=hidden \ -+CXXFLAGS += -std=c++14 -fvisibility=hidden \ - -Wall -Wextra -Wpedantic -Werror -Werror=shadow -Wdouble-promotion - - # Validate that the APP parameter is a supported value, and patch CXXFLAGS - ifeq ($(APP),astcenc) - # Nothing to set up - else - ifeq ($(APP),astcdec) - CXXFLAGS += -DASTCENC_DECOMPRESS_ONLY - else - $(error Unsupported app, use APP=astcenc/astcdec) diff --git a/projects/astc-encoder/astc_load_decompress_image_fuzzer.cc b/projects/astc-encoder/astc_load_decompress_image_fuzzer.cc deleted file mode 100644 index 433afeb25..000000000 --- a/projects/astc-encoder/astc_load_decompress_image_fuzzer.cc +++ /dev/null @@ -1,103 +0,0 @@ -// 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. - -#include "astcenc_internal.h" -#include "astcenccli_internal.h" - -#include -#include -#include - -static constexpr uint8_t kUint8Max = std::numeric_limits::max(); - -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - - astc_compressed_image image_comp; - astcenc_profile profile; - int out_bitness; - FuzzedDataProvider stream(data, size); - - const astcenc_profile profiles[] = {ASTCENC_PRF_LDR, ASTCENC_PRF_LDR_SRGB, - ASTCENC_PRF_HDR, - ASTCENC_PRF_HDR_RGB_LDR_A}; - - int profile_type = stream.ConsumeIntegralInRange(0, 3); - profile = profiles[profile_type]; - out_bitness = 8 << (profile_type / 2); - - // Avoid dividing by zero - uint8_t block_x = stream.ConsumeIntegralInRange(1, kUint8Max); - uint8_t block_y = stream.ConsumeIntegralInRange(1, kUint8Max); - uint8_t block_z = stream.ConsumeIntegralInRange(1, kUint8Max); - - // Reference file consumes 3 bytes for each, so we define a maximum value - unsigned int dim_x = - stream.ConsumeIntegralInRange(1, ~(0xff << 24)); - unsigned int dim_y = - stream.ConsumeIntegralInRange(1, ~(0xff << 24)); - unsigned int dim_z = - stream.ConsumeIntegralInRange(1, ~(0xff << 24)); - - unsigned int xblocks = (dim_x + block_x - 1) / block_x; - unsigned int yblocks = (dim_y + block_y - 1) / block_y; - unsigned int zblocks = (dim_z + block_z - 1) / block_z; - - // Following the structure of - // ARM-software/astc-encoder/Source/astcenccli_toplevel.cpp:main(), located at - // https://github.com/ARM-software/astc-encoder/blob/master/Source/astcenccli_toplevel.cpp - size_t buffer_size = xblocks * yblocks * zblocks * 16; - std::vector buffer = stream.ConsumeBytes(buffer_size); - - image_comp.data = buffer.data(); - image_comp.data_len = buffer.size(); - image_comp.block_x = block_x; - image_comp.block_y = block_y; - image_comp.block_z = block_z; - image_comp.dim_x = dim_x; - image_comp.dim_y = dim_y; - image_comp.dim_z = dim_z; - - astcenc_config config{}; - astcenc_preset preset = ASTCENC_PRE_FAST; - if (astcenc_config_init(profile, image_comp.block_x, image_comp.block_y, - image_comp.block_z, preset, 0, - config) != ASTCENC_SUCCESS) - return 0; - - astcenc_swizzle default_swizzle{ASTCENC_SWZ_R, ASTCENC_SWZ_G, ASTCENC_SWZ_B, - ASTCENC_SWZ_A}; - - // Initialize cli_config_options with default values - cli_config_options cli_config{/*thread_count=*/0, - /*array_size=*/1, - /*silent_mode=*/false, - /*y_flip=*/false, - /*low_fstop=*/-10, - /*high_fstop=*/10, - /*swz_encode=*/default_swizzle, - /*swz_decode=*/default_swizzle}; - - astcenc_context *codec_context; - if (astcenc_context_alloc(config, cli_config.thread_count, &codec_context) != - ASTCENC_SUCCESS) - return 0; - - astcenc_image *image_decomp_out = alloc_image( - out_bitness, image_comp.dim_x, image_comp.dim_y, image_comp.dim_z, 0); - - astcenc_decompress_image(codec_context, image_comp.data, image_comp.data_len, - *image_decomp_out, cli_config.swz_decode); - - return 0; -} diff --git a/projects/astc-encoder/build.sh b/projects/astc-encoder/build.sh index 357812b46..e34e5b096 100755 --- a/projects/astc-encoder/build.sh +++ b/projects/astc-encoder/build.sh @@ -15,15 +15,5 @@ # ################################################################################ -# build project -patch Makefile Makefile.patch -make -j$(nproc) BUILD=debug -ar -qc libastc.a *.o - -# build fuzzers -for fuzzer in $SRC/*_fuzzer.cc; do - $CXX $CXXFLAGS \ - -DASTCENC_SSE=0 -DASTCENC_AVX=0 -DASTCENC_POPCNT=0 -DASTCENC_VECALIGN=16 \ - -I. -std=c++14 $fuzzer $LIB_FUZZING_ENGINE $SRC/astc-encoder/Source/libastc.a \ - -o $OUT/$(basename -s .cc $fuzzer) -done +# build project and project-hosted fuzzers +$SRC/astc-encoder/Source/Fuzzers/build.sh