golang: add fuzzer (#8402)

Signed-off-by: AdamKorcz <adam@adalogics.com>

Signed-off-by: AdamKorcz <adam@adalogics.com>
This commit is contained in:
AdamKorcz 2022-09-03 11:20:15 +01:00 committed by GitHub
parent 6407cd0ea0
commit b5c6cd48c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 32 additions and 1 deletions

View File

@ -36,6 +36,7 @@ COPY build.sh text_fuzzer.go \
elf_fuzzer.go \
tiff_fuzzer.go \
fuzz_tiff_decode.options \
openpgp_fuzzer.go $SRC/
openpgp_fuzzer.go \
webp_fuzzer.go $SRC/
WORKDIR $SRC/golang

View File

@ -107,6 +107,11 @@ cd $SRC/instrumentation && go run main.go $SRC/crypto && cd -
go mod tidy
compile_go_fuzzer . FuzzOpenpgpRead fuzz_openpgp_read
cd $SRC/image/webp
cp $SRC/webp_fuzzer.go ./
compile_go_fuzzer . FuzzWebpDecode fuzz_webp_decode
zip $OUT/fuzz_webp_decode_seed_corpus.zip $SRC/image/testdata/*.webp
cd $SRC/image/tiff
cp $SRC/tiff_fuzzer.go ./
compile_go_fuzzer . FuzzTiffDecode fuzz_tiff_decode

View File

@ -0,0 +1,25 @@
// Copyright 2022 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.
//
package webp
import (
"bytes"
)
func FuzzWebpDecode(data []byte) int {
_, _ = Decode(bytes.NewReader(data))
return 1
}