mirror of https://github.com/google/oss-fuzz.git
file (aka libmagic) fuzzers. Fixes #63
This commit is contained in:
parent
c37f5a2550
commit
596c4b6baa
|
@ -7,6 +7,7 @@ Targets integrated with oss-fuzz.
|
|||
| [boringssl](https://boringssl.googlesource.com/boringssl/) | [/targets/boringssl](boringssl) |
|
||||
| [curl](https://curl.haxx.se/) | [/targets/curl](curl) |
|
||||
| [expat](http://expat.sourceforge.net/) | [/targets/expat](expat) |
|
||||
| [file (aka libmagic)](http://www.darwinsys.com/file/) | [/targets/file](file) |
|
||||
| [freetype2](https://www.freetype.org/) | [/targets/freetype2](freetype2) |
|
||||
| [harfbuzz](http://www.harfbuzz.org/) | [/targets/harfbuzz](harfbuzz) |
|
||||
| [icu](http://site.icu-project.org/) | [/targets/icu](icu) |
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
# Copyright 2016 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 ossfuzz/base-libfuzzer
|
||||
MAINTAINER your@email.com
|
||||
RUN apt-get install -y make autoconf automake libtool shtool
|
||||
RUN git clone https://github.com/file/file.git
|
||||
COPY build.sh magic_fuzzer.cc /src/
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright 2016 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.
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
def libfuzzerBuild = fileLoader.fromGit('infra/libfuzzer-pipeline.groovy',
|
||||
'https://github.com/google/oss-fuzz.git')
|
||||
|
||||
libfuzzerBuild {
|
||||
git = "https://github.com/file/file.git"
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash -eu
|
||||
# Copyright 2016 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.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
cd /src/file
|
||||
|
||||
autoreconf -i
|
||||
./configure --enable-static
|
||||
make V=1 all
|
||||
|
||||
$CXX $CXXFLAGS -std=c++11 -Isrc/ \
|
||||
/src/magic_fuzzer.cc -o /out/magic_fuzzer \
|
||||
-lfuzzer ./src/.libs/libmagic.a $FUZZER_LDFLAGS
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright 2016 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 <magic.h>
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
if (size < 1)
|
||||
return 0;
|
||||
|
||||
magic_t magic = magic_open(MAGIC_NONE);
|
||||
magic_buffer(magic, data, size);
|
||||
magic_close(magic);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue