diff options
author | Jamie Pinheiro <jamiepinheiro@gmail.com> | 2020-06-02 13:47:31 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-02 10:47:31 -0700 |
commit | bba24d396e6ff57545caf8a1baf2d871ec74fb49 (patch) | |
tree | b9b9c2e83e0ea72078706f57a411e88a5d084d45 /projects/libraw | |
parent | bd66ce05ce27b224c81040c873b34e0bf0c66753 (diff) | |
download | oss-fuzz-bba24d396e6ff57545caf8a1baf2d871ec74fb49.tar.gz |
[LibRaw] Initial integration (#3918)
* Init integration
* Fix formatting
* Add size check
* Update maintainers
* PR Feedback
* Add newline
* Disable UBSan vptr
* Disable building examples
* Remove disabling UBSan vptr
Co-authored-by: Jamie Pinheiro <pinheirojamie@google.com>
Diffstat (limited to 'projects/libraw')
-rw-r--r-- | projects/libraw/Dockerfile | 22 | ||||
-rwxr-xr-x | projects/libraw/build.sh | 26 | ||||
-rw-r--r-- | projects/libraw/libraw_fuzzer.cc | 48 | ||||
-rw-r--r-- | projects/libraw/project.yaml | 10 |
4 files changed, 106 insertions, 0 deletions
diff --git a/projects/libraw/Dockerfile b/projects/libraw/Dockerfile new file mode 100644 index 000000000..437bd07b2 --- /dev/null +++ b/projects/libraw/Dockerfile @@ -0,0 +1,22 @@ +# 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 +MAINTAINER TODO@gmail.com +RUN apt-get update && apt-get install -y make autoconf automake libtool pkg-config +RUN git clone --depth 1 https://github.com/libraw/libraw +WORKDIR libraw +COPY build.sh libraw_fuzzer.cc $SRC/ diff --git a/projects/libraw/build.sh b/projects/libraw/build.sh new file mode 100755 index 000000000..20dbc4562 --- /dev/null +++ b/projects/libraw/build.sh @@ -0,0 +1,26 @@ +#!/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. +# +################################################################################ + +# build project +./mkdist.sh +./configure --disable-examples +make + +# build fuzzers +$CXX $CXXFLAGS -std=c++11 -Ilibraw \ + $SRC/libraw_fuzzer.cc -o $OUT/libraw_fuzzer \ + $LIB_FUZZING_ENGINE lib/.libs/libraw.a diff --git a/projects/libraw/libraw_fuzzer.cc b/projects/libraw/libraw_fuzzer.cc new file mode 100644 index 000000000..25c101f59 --- /dev/null +++ b/projects/libraw/libraw_fuzzer.cc @@ -0,0 +1,48 @@ +/* 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 <stddef.h> +#include <stdint.h> + +#include <string> + +#include <libraw.h> + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { + // Input less than 10mb + if (size > 10000000) { + return 0; + } + + LibRaw lib_raw; + + int result = lib_raw.open_buffer( + const_cast<char*>(reinterpret_cast<const char*>(data)), size); + if (result != LIBRAW_SUCCESS) { + return 0; + } + + result = lib_raw.unpack(); + if (result != LIBRAW_SUCCESS) { + return 0; + } + + result = lib_raw.dcraw_process(); + if (result != LIBRAW_SUCCESS) { + return 0; + } + + return 0; +} diff --git a/projects/libraw/project.yaml b/projects/libraw/project.yaml new file mode 100644 index 000000000..301821d35 --- /dev/null +++ b/projects/libraw/project.yaml @@ -0,0 +1,10 @@ +homepage: "https://www.libraw.org/" +language: c++ +primary_contact: "jesteele@google.com" +auto_ccs: + - "nchusid@google.com" + - "pinheirojamie@google.com" +sanitizers: + - address + - memory + - undefined |