Skip to content

Commit

Permalink
Revert "oss-fuzz: Update the README file, the Docker file and the bui…
Browse files Browse the repository at this point in the history
…ld script"

This reverts commit 3117b5f.

A regression was introduced. (Oopsie!)

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
  • Loading branch information
ctruta committed Sep 19, 2024
1 parent cd5e582 commit 529e69e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 27 deletions.
15 changes: 6 additions & 9 deletions contrib/oss-fuzz/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# Copyright 2024 Cosmin Truta
# Copyright 2017 Glenn Randers-Pehrson
# Copyright 2016 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -17,12 +15,11 @@
################################################################################

FROM gcr.io/oss-fuzz-base/base-builder

MAINTAINER glennrp@gmail.com
RUN apt-get update && \
apt-get install -y make autoconf automake libtool zlib1g-dev

RUN git clone --depth=1 https://github.com/pnggroup/libpng.git && \
git clone --depth=1 https://github.com/madler/zlib.git && \
cp libpng/contrib/oss-fuzz/build.sh $SRC
apt-get install -y make autoconf automake libtool

WORKDIR /home/libpng
RUN git clone --depth 1 https://github.com/madler/zlib.git
RUN git clone --depth 1 https://github.com/glennrp/libpng.git
RUN cp libpng/contrib/oss-fuzz/build.sh $SRC
WORKDIR libpng
4 changes: 0 additions & 4 deletions contrib/oss-fuzz/README.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
libpng additions to oss-fuzz
============================

Copyright (c) 2024 Cosmin Truta
Copyright (c) 2017 Glenn Randers-Pehrson

This code is released under the libpng license.
Expand Down
31 changes: 17 additions & 14 deletions contrib/oss-fuzz/build.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#!/usr/bin/env bash
set -eu
#!/bin/bash -eu

# Copyright 2024 Cosmin Truta
# Copyright 2017 Glenn Randers-Pehrson
# Copyright 2017-2018 Glenn Randers-Pehrson
# Copyright 2016 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -17,31 +15,36 @@ set -eu
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Revisions by Glenn Randers-Pehrson, 2017:
# 1. Build only the library, not the tools (changed "make -j$(nproc) all" to
# "make -j$(nproc) libpng16.la").
# 2. Disabled WARNING and WRITE options in pnglibconf.dfa.
# 3. Build zlib alongside libpng
################################################################################

# Disable logging via library build configuration control.
sed -e "s/option STDIO/option STDIO disabled/" \
-e "s/option WARNING /option WARNING disabled/" \
-e "s/option WRITE enables WRITE_INT_FUNCTIONS/option WRITE disabled/" \
scripts/pnglibconf.dfa >scripts/pnglibconf.dfa.tmp
mv -f scripts/pnglibconf.dfa.tmp scripts/pnglibconf.dfa
cat scripts/pnglibconf.dfa | \
sed -e "s/option STDIO/option STDIO disabled/" \
-e "s/option WARNING /option WARNING disabled/" \
-e "s/option WRITE enables WRITE_INT_FUNCTIONS/option WRITE disabled/" \
> scripts/pnglibconf.dfa.temp
mv scripts/pnglibconf.dfa.temp scripts/pnglibconf.dfa

# Build the libpng library ("libpng16.la"), excluding the auxiliary tools.
# build the libpng library.
autoreconf -f -i
./configure --with-libpng-prefix=OSS_FUZZ_
make -j$(nproc) clean
make -j$(nproc) libpng16.la

# Build libpng_read_fuzzer.
# build libpng_read_fuzzer.
$CXX $CXXFLAGS -std=c++11 -I. \
$SRC/libpng/contrib/oss-fuzz/libpng_read_fuzzer.cc \
-o $OUT/libpng_read_fuzzer \
-lFuzzingEngine .libs/libpng16.a -lz

# Add seed corpus.
# add seed corpus.
find $SRC/libpng -name "*.png" | grep -v crashers | \
xargs zip $OUT/libpng_read_fuzzer_seed_corpus.zip

cp $SRC/libpng/contrib/oss-fuzz/*.dict \
$SRC/libpng/contrib/oss-fuzz/*.options \
$OUT/
$SRC/libpng/contrib/oss-fuzz/*.options $OUT/

0 comments on commit 529e69e

Please sign in to comment.