mirror of
https://invent.kde.org/frameworks/kimageformats.git
synced 2025-09-14 18:15:13 -04:00
Move fuzz target and build script into KImageFormats repository
This commit is contained in:
202
LICENSES/Apache-2.0.txt
Normal file
202
LICENSES/Apache-2.0.txt
Normal file
@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
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.
|
@ -230,9 +230,7 @@ kimageformats_write_tests(FUZZ 1
|
||||
|
||||
Plugins are also tested with [OSS-Fuzz](https://google.github.io/oss-fuzz/)
|
||||
project to identify possible security issues. When adding a new plugin it is
|
||||
also necessary to add it to the test in the [kimageformats
|
||||
project](https://github.com/google/oss-fuzz/tree/master/projects/kimageformats)
|
||||
on OSS-Fuzz.
|
||||
also necessary to add it to the test in the [ossfuzz](ossfuzz) directory.
|
||||
|
||||
## TODO
|
||||
|
||||
|
194
autotests/ossfuzz/build_fuzzers.sh
Executable file
194
autotests/ossfuzz/build_fuzzers.sh
Executable file
@ -0,0 +1,194 @@
|
||||
#!/bin/bash -eu
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2020 Google LLC
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Copyright 2020 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.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# build zstd
|
||||
cd $SRC/zstd
|
||||
cmake -S build/cmake -DBUILD_SHARED_LIBS=OFF
|
||||
make install -j$(nproc)
|
||||
|
||||
# Build zlib
|
||||
cd $SRC/zlib
|
||||
./configure --static
|
||||
make install -j$(nproc)
|
||||
|
||||
# Build bzip2
|
||||
# Inspired from ../bzip2/build
|
||||
cd $SRC
|
||||
tar xzf bzip2-*.tar.gz && rm -f bzip2-*.tar.gz
|
||||
cd bzip2-*
|
||||
SRCL=(blocksort.o huffman.o crctable.o randtable.o compress.o decompress.o bzlib.o)
|
||||
|
||||
for source in ${SRCL[@]}; do
|
||||
name=$(basename $source .o)
|
||||
$CC $CFLAGS -c ${name}.c
|
||||
done
|
||||
rm -f libbz2.a
|
||||
ar cq libbz2.a ${SRCL[@]}
|
||||
cp -f bzlib.h /usr/local/include
|
||||
cp -f libbz2.a /usr/local/lib
|
||||
|
||||
# Build xz
|
||||
export ORIG_CFLAGS="${CFLAGS}"
|
||||
export ORIG_CXXFLAGS="${CXXFLAGS}"
|
||||
unset CFLAGS
|
||||
unset CXXFLAGS
|
||||
cd $SRC/xz
|
||||
./autogen.sh --no-po4a --no-doxygen
|
||||
./configure --enable-static --disable-debug --disable-shared --disable-xz --disable-xzdec --disable-lzmainfo
|
||||
make install -j$(nproc)
|
||||
export CFLAGS="${ORIG_CFLAGS}"
|
||||
export CXXFLAGS="${ORIG_CXXFLAGS}"
|
||||
|
||||
# Build qt
|
||||
cd $SRC/qtbase
|
||||
./configure -no-glib -qt-libpng -qt-pcre -opensource -confirm-license -static -no-opengl -no-icu -platform linux-clang-libc++ -debug -prefix /usr -no-feature-widgets -no-feature-sql -no-feature-network -no-feature-xml -no-feature-dbus -no-feature-printsupport
|
||||
cmake --build . --parallel $(nproc)
|
||||
cmake --install .
|
||||
|
||||
# Build extra-cmake-modules
|
||||
cd $SRC/extra-cmake-modules
|
||||
cmake . -DBUILD_TESTING=OFF
|
||||
make install -j$(nproc)
|
||||
|
||||
cd $SRC/karchive
|
||||
rm -rf poqm
|
||||
cmake . -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DCMAKE_INSTALL_PREFIX=/usr/local
|
||||
make install -j$(nproc)
|
||||
|
||||
# Build JXRlib
|
||||
cd $SRC/jxrlib
|
||||
make -j$(nproc)
|
||||
|
||||
# Build LibRaw
|
||||
cd $SRC/LibRaw
|
||||
TMP_CFLAGS=$CFLAGS
|
||||
TMP_CXXFLAGS=$CXXFLAGS
|
||||
CFLAGS="$CFLAGS -fno-sanitize=function,vptr"
|
||||
CXXFLAGS="$CXXFLAGS -fno-sanitize=function,vptr"
|
||||
autoreconf --install
|
||||
./configure --disable-examples
|
||||
make -j$(nproc)
|
||||
make install -j$(nproc)
|
||||
CFLAGS=$TMP_CFLAGS
|
||||
CXXFLAGS=$TMP_CXXFLAGS
|
||||
|
||||
|
||||
# Build aom
|
||||
cd $SRC/aom
|
||||
mkdir build.libavif
|
||||
cd build.libavif
|
||||
extra_libaom_flags='-DAOM_MAX_ALLOCABLE_MEMORY=536870912 -DDO_RANGE_CHECK_CLAMP=1'
|
||||
cmake -DBUILD_SHARED_LIBS=0 -DENABLE_DOCS=0 -DENABLE_EXAMPLES=0 -DENABLE_TESTDATA=0 -DENABLE_TESTS=0 -DENABLE_TOOLS=0 -DCONFIG_PIC=1 -DAOM_TARGET_CPU=generic -DCONFIG_SIZE_LIMIT=1 -DDECODE_HEIGHT_LIMIT=12288 -DDECODE_WIDTH_LIMIT=12288 -DAOM_EXTRA_C_FLAGS="${extra_libaom_flags}" -DAOM_EXTRA_CXX_FLAGS="${extra_libaom_flags}" ..
|
||||
make -j$(nproc)
|
||||
make install -j$(nproc)
|
||||
|
||||
# Build libavif
|
||||
cd $SRC/libavif
|
||||
ln -s "$SRC/aom" "$SRC/libavif/ext/"
|
||||
mkdir build
|
||||
cd build
|
||||
CFLAGS="$CFLAGS -fPIC" cmake -DBUILD_SHARED_LIBS=OFF -DAVIF_ENABLE_WERROR=OFF -DAVIF_CODEC_AOM=LOCAL -DAVIF_LIBYUV=OFF ..
|
||||
make -j$(nproc)
|
||||
|
||||
# Build libde265
|
||||
cd $SRC/libde265
|
||||
cmake -DBUILD_SHARED_LIBS=OFF -DDISABLE_SSE=ON .
|
||||
make -j$(nproc)
|
||||
make install -j$(nproc)
|
||||
|
||||
# Build openjpeg
|
||||
cd $SRC/openjpeg
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON -DBUILD_CODEC=OFF ..
|
||||
make -j$(nproc)
|
||||
make install -j$(nproc)
|
||||
|
||||
# build openh264
|
||||
cd $SRC/openh264
|
||||
make USE_ASM=No BUILDTYPE=Debug install-static -j$(nproc)
|
||||
|
||||
# Build openexr
|
||||
cd $SRC/openexr
|
||||
mkdir _build
|
||||
cd _build
|
||||
cmake -DBUILD_SHARED_LIBS=OFF ..
|
||||
make -j$(nproc)
|
||||
make install -j$(nproc)
|
||||
|
||||
# Build libheif
|
||||
cd $SRC/libheif
|
||||
#Reduce max width and height to avoid allocating too much memory
|
||||
sed -i "s/static const int MAX_IMAGE_WIDTH = 32768;/static const int MAX_IMAGE_WIDTH = 8192;/g" libheif/security_limits.h
|
||||
sed -i "s/static const int MAX_IMAGE_HEIGHT = 32768;/static const int MAX_IMAGE_HEIGHT = 8192;/g" libheif/security_limits.h
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DBUILD_SHARED_LIBS=OFF -DENABLE_PLUGIN_LOADING=OFF -DWITH_DAV1D=OFF -DWITH_EXAMPLES=OFF -DWITH_LIBDE265=ON -DWITH_RAV1E=OFF -DWITH_RAV1E_PLUGIN=OFF -DWITH_SvtEnc=OFF -DWITH_SvtEnc_PLUGIN=OFF -DWITH_X265=OFF -DWITH_OpenJPEG_DECODER=ON -DWITH_OpenH264_DECODER=ON ..
|
||||
make -j$(nproc)
|
||||
make install -j$(nproc)
|
||||
|
||||
# Build libjxl
|
||||
cd $SRC/libjxl
|
||||
mkdir build
|
||||
cd build
|
||||
CXXFLAGS="$CXXFLAGS -DHWY_COMPILE_ONLY_SCALAR" cmake -DBUILD_SHARED_LIBS=OFF -DBUILD_TESTING=OFF -DJPEGXL_ENABLE_BENCHMARK=OFF -DJPEGXL_ENABLE_DOXYGEN=OFF -DJPEGXL_ENABLE_EXAMPLES=OFF -DJPEGXL_ENABLE_JNI=OFF -DJPEGXL_ENABLE_JPEGLI=OFF -DJPEGXL_ENABLE_JPEGLI_LIBJPEG=OFF -DJPEGXL_ENABLE_MANPAGES=OFF -DJPEGXL_ENABLE_OPENEXR=OFF -DJPEGXL_ENABLE_PLUGINS=OFF -DJPEGXL_ENABLE_SJPEG=OFF -DJPEGXL_ENABLE_SKCMS=ON -DJPEGXL_ENABLE_TCMALLOC=OFF -DJPEGXL_ENABLE_TOOLS=OFF -DJPEGXL_ENABLE_FUZZERS=OFF ..
|
||||
make -j$(nproc) jxl jxl_cms jxl_threads
|
||||
|
||||
cd $SRC/kimageformats
|
||||
HANDLER_TYPES="ANIHandler ani
|
||||
QAVIFHandler avif
|
||||
QDDSHandler dds
|
||||
EXRHandler exr
|
||||
HDRHandler hdr
|
||||
HEIFHandler heif
|
||||
IFFHandler iff
|
||||
JP2Handler jp2
|
||||
QJpegXLHandler jxl
|
||||
JXRHandler jxr
|
||||
KraHandler kra
|
||||
OraHandler ora
|
||||
PCXHandler pcx
|
||||
PFMHandler pfm
|
||||
SoftimagePICHandler pic
|
||||
PSDHandler psd
|
||||
PXRHandler pxr
|
||||
QOIHandler qoi
|
||||
RASHandler ras
|
||||
RAWHandler raw
|
||||
RGBHandler rgb
|
||||
ScitexHandler sct
|
||||
TGAHandler tga
|
||||
XCFHandler xcf"
|
||||
|
||||
echo "$HANDLER_TYPES" | while read class format; do
|
||||
(
|
||||
fuzz_target_name=kimgio_${format}_fuzzer
|
||||
|
||||
/usr/libexec/moc $SRC/kimageformats/src/imageformats/$format.cpp -o $format.moc
|
||||
header=`ls $SRC/kimageformats/src/imageformats/$format*.h`
|
||||
/usr/libexec/moc $header -o moc_`basename $header .h`.cpp
|
||||
$CXX $CXXFLAGS -fPIC -DHANDLER=$class -std=c++17 autotests/ossfuzz/kimgio_fuzzer.cc $SRC/kimageformats/src/imageformats/$format.cpp $SRC/kimageformats/src/imageformats/scanlineconverter.cpp $SRC/kimageformats/src/imageformats/microexif.cpp $SRC/kimageformats/src/imageformats/chunks.cpp -o $OUT/$fuzz_target_name -DJXL_STATIC_DEFINE -DJXL_THREADS_STATIC_DEFINE -DJXL_CMS_STATIC_DEFINE -DINITGUID -I $SRC/kimageformats/src/imageformats/ -I $SRC/libavif/include/ -I $SRC/libjxl/build/lib/include/ -I $SRC/libjxl/lib/include/ -I /usr/local/include/OpenEXR/ -I /usr/local/include/KF6/KArchive/ -I /usr/local/include/openjpeg-2.5 -I /usr/local/include/Imath -I $SRC/jxrlib/common/include -I $SRC/jxrlib/jxrgluelib -I $SRC/jxrlib/image/sys -I /usr/include/QtCore/ -I /usr/include/QtGui/ -I . $SRC/libavif/build/libavif.a /usr/local/lib/libheif.a /usr/local/lib/libde265.a /usr/local/lib/libopenh264.a $SRC/aom/build.libavif/libaom.a $SRC/libjxl/build/lib/libjxl_threads.a $SRC/libjxl/build/lib/libjxl.a $SRC/libjxl/build/lib/libjxl_cms.a $SRC/libjxl/build/third_party/highway/libhwy.a $SRC/libjxl/build/third_party/brotli/libbrotlidec.a $SRC/libjxl/build/third_party/brotli/libbrotlienc.a $SRC/libjxl/build/third_party/brotli/libbrotlicommon.a -lQt6Gui -lQt6Core -lQt6BundledLibpng -lQt6BundledHarfbuzz -lm -lQt6BundledPcre2 -ldl -lpthread $LIB_FUZZING_ENGINE /usr/local/lib/libz.a -lKF6Archive /usr/local/lib/libz.a /usr/local/lib/libraw.a /usr/local/lib/libOpenEXR-3_3.a /usr/local/lib/libIex-3_3.a /usr/local/lib/libImath-3_1.a /usr/local/lib/libIlmThread-3_3.a /usr/local/lib/libOpenEXRCore-3_3.a /usr/local/lib/libOpenEXRUtil-3_3.a /usr/local/lib/libopenjp2.a /usr/local/lib/libzstd.a $SRC/jxrlib/build/libjxrglue.a $SRC/jxrlib/build/libjpegxr.a -llzma /usr/local/lib/libbz2.a -lclang_rt.builtins
|
||||
|
||||
# -lclang_rt.builtins in the previous line is a temporary workaround to avoid a linker error "undefined reference to __truncsfhf2". Investigate why this is needed here, but not anywhere else, and possibly remove it.
|
||||
|
||||
find . -name "*.${format}" | zip -q $OUT/${fuzz_target_name}_seed_corpus.zip -@
|
||||
)
|
||||
done
|
76
autotests/ossfuzz/kimgio_fuzzer.cc
Normal file
76
autotests/ossfuzz/kimgio_fuzzer.cc
Normal file
@ -0,0 +1,76 @@
|
||||
/*
|
||||
# SPDX-FileCopyrightText: 2018 Google Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Copyright 2018 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.
|
||||
#
|
||||
################################################################################
|
||||
*/
|
||||
|
||||
/*
|
||||
Usage:
|
||||
python infra/helper.py build_image kimageformats
|
||||
python infra/helper.py build_fuzzers --sanitizer undefined|address|memory kimageformats
|
||||
python infra/helper.py run_fuzzer kimageformats kimgio_[ani|avif|dds|exr|hdr|heif|iff|jp2|jxl|jxr|kra|ora|pcx|pfm|pic|psd|pxr|qoi|ras|raw|rgb|sct|tga|xcf]_fuzzer
|
||||
*/
|
||||
|
||||
#include <QBuffer>
|
||||
#include <QCoreApplication>
|
||||
#include <QImage>
|
||||
|
||||
#include "ani_p.h"
|
||||
#include "avif_p.h"
|
||||
#include "dds_p.h"
|
||||
#include "exr_p.h"
|
||||
#include "hdr_p.h"
|
||||
#include "heif_p.h"
|
||||
#include "iff_p.h"
|
||||
#include "jp2_p.h"
|
||||
#include "jxl_p.h"
|
||||
#include "jxr_p.h"
|
||||
#include "kra.h"
|
||||
#include "ora.h"
|
||||
#include "pcx_p.h"
|
||||
#include "pfm_p.h"
|
||||
#include "pic_p.h"
|
||||
#include "psd_p.h"
|
||||
#include "pxr_p.h"
|
||||
#include "qoi_p.h"
|
||||
#include "ras_p.h"
|
||||
#include "raw_p.h"
|
||||
#include "rgb_p.h"
|
||||
#include "sct_p.h"
|
||||
#include "tga_p.h"
|
||||
#include "xcf_p.h"
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
int argc = 0;
|
||||
QCoreApplication a(argc, nullptr);
|
||||
|
||||
QImageIOHandler* handler = new HANDLER();
|
||||
|
||||
QImage i;
|
||||
QBuffer b;
|
||||
b.setData((const char *)data, size);
|
||||
b.open(QIODevice::ReadOnly);
|
||||
handler->setDevice(&b);
|
||||
handler->canRead();
|
||||
handler->read(&i);
|
||||
|
||||
delete handler;
|
||||
|
||||
return 0;
|
||||
}
|
44
autotests/ossfuzz/prepare_build.sh
Executable file
44
autotests/ossfuzz/prepare_build.sh
Executable file
@ -0,0 +1,44 @@
|
||||
#!/bin/bash -eu
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2018 Google Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
# Based on https://github.com/google/oss-fuzz/blob/33aab4a70dc4b5811143d214536584a8c8cb3924/projects/kimageformats/Dockerfile
|
||||
# Copyright 2018 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.
|
||||
#
|
||||
################################################################################
|
||||
|
||||
apt-get update && \
|
||||
apt-get install -y cmake make autoconf automake autopoint libtool \
|
||||
wget po4a ninja-build pkgconf
|
||||
|
||||
git clone --depth 1 https://github.com/madler/zlib.git
|
||||
git clone --depth 1 -b v1.5.7 https://github.com/facebook/zstd.git
|
||||
wget https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz
|
||||
git clone https://github.com/tukaani-project/xz.git
|
||||
git clone --depth 1 --branch=RB-3.3 https://github.com/AcademySoftwareFoundation/openexr.git
|
||||
git clone --depth 1 -b master https://invent.kde.org/frameworks/extra-cmake-modules.git
|
||||
git clone --depth 1 --branch=dev git://code.qt.io/qt/qtbase.git
|
||||
git clone --depth 1 --branch=dev git://code.qt.io/qt/qttools.git
|
||||
git clone --depth 1 -b master https://invent.kde.org/frameworks/karchive.git
|
||||
git clone --depth 1 -b v3.12.0 https://aomedia.googlesource.com/aom
|
||||
git clone --depth 1 -b v1.2.1 https://github.com/AOMediaCodec/libavif.git
|
||||
git clone --depth 1 https://github.com/strukturag/libde265.git
|
||||
git clone --depth 1 -b v2.5.3 https://github.com/uclouvain/openjpeg.git
|
||||
git clone --depth 1 https://github.com/strukturag/libheif.git
|
||||
git clone --depth=1 --branch v0.11.x --recursive --shallow-submodules https://github.com/libjxl/libjxl.git
|
||||
git clone --depth 1 https://github.com/LibRaw/LibRaw
|
||||
git clone --depth 1 https://github.com/mircomir/jxrlib.git
|
||||
git clone --depth 1 -b v2.6.0 https://github.com/cisco/openh264.git
|
Reference in New Issue
Block a user