GraphicsMagick: fuzzing/oss-fuzz-build.sh: Add a hack so that li...

GraphicsMagick Commits <[email protected]> Sun, 17 Nov 2024 16:35:29 -0600
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.35670.1731882970.7833.graphicsmagick-commit@lists.sourceforge.net>
changeset bdf424d91f42 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=bdf424d91f42
summary: fuzzing/oss-fuzz-build.sh: Add a hack so that libx265 installs x265.pc

diffstat:

 ChangeLog                              |   9 +++-
 VisualMagick/installer/inc/version.isx |   4 +-
 fuzzing/README.txt                     |  69 +++++++++++++++++++++++++++++++--
 fuzzing/oss-fuzz-build.sh              |  36 ++++++++--------
 magick/version.h                       |   4 +-
 www/ChangeLog.html                     |  10 ++++-
 6 files changed, 103 insertions(+), 29 deletions(-)

diffs (233 lines):

diff -r c7bd6398ff60 -r bdf424d91f42 ChangeLog
--- a/ChangeLog	Thu Nov 14 17:40:00 2024 -0600
+++ b/ChangeLog	Sun Nov 17 16:34:49 2024 -0600
@@ -1,6 +1,13 @@
+2024-11-17  Bob Friesenhahn  <[email protected]>
+
+	* fuzzing/README.txt: Add more fuzzing notes.
+
+	* fuzzing/oss-fuzz-build.sh: Add a hack so that libx265 installs
+	x265.pc.
+
 2024-11-14  Bob Friesenhahn  <[email protected]>
 
-	* tests/rwfile.c: Fix appending file name.
+	* tests/rwfile.c: Fix appending file extension.
 
 	* coders/bmp.c (ReadBMPImage): Assure that opacity channel is
 	initialized, even if matte is not true.  May help regarding
diff -r c7bd6398ff60 -r bdf424d91f42 VisualMagick/installer/inc/version.isx
--- a/VisualMagick/installer/inc/version.isx	Thu Nov 14 17:40:00 2024 -0600
+++ b/VisualMagick/installer/inc/version.isx	Sun Nov 17 16:34:49 2024 -0600
@@ -10,5 +10,5 @@
 
 #define public MagickPackageName "GraphicsMagick"
 #define public MagickPackageVersion "1.4"
-#define public MagickPackageVersionAddendum ".020241114"
-#define public MagickPackageReleaseDate "snapshot-20241114"
+#define public MagickPackageVersionAddendum ".020241117"
+#define public MagickPackageReleaseDate "snapshot-20241117"
diff -r c7bd6398ff60 -r bdf424d91f42 fuzzing/README.txt
--- a/fuzzing/README.txt	Thu Nov 14 17:40:00 2024 -0600
+++ b/fuzzing/README.txt	Sun Nov 17 16:34:49 2024 -0600
@@ -10,21 +10,80 @@
 
 See https://google.github.io/oss-fuzz/advanced-topics/reproducing/ for instructions for building/executing oss-fuzz targets locally.
 
-Cloning OSS-Fuzz:
+Check GM build status::
+
+  xdg-open https://oss-fuzz-build-logs.storage.googleapis.com/index.html#graphicsmagick
+
+Check GM open issues::
+
+  xdg-open https://issues.oss-fuzz.com/savedsearches/6886196
+
+Read OSS-Fuzz usage documentation::
+
+  xdg-open https://google.github.io/oss-fuzz/
+
+Clone the OSS-Fuzz git repository::
 
   $ git clone --depth=1 https://github.com/google/oss-fuzz.git
   $ cd oss-fuzz
 
+List existing Docker images::
+
+  docker image ls
+
+Clean up dangling (stale) Docker images::
+
+  docker ps -a -q | xargs -I {} docker rm {} ; docker images -q -f dangling=true | xargs -I {} docker rmi -f {}; docker volume ls -qf dangling=true | xargs -I {} docker volume rm {}
+
 Pull the latest Docker images::
 
   $ python infra/helper.py pull_images
 
-Build the image and the fuzzers::
+Remove the existing project image::
+
+  docker image rm gcr.io/oss-fuzz/graphicsmagick
+
+Build the project image::
+
+  python infra/helper.py build_image graphicsmagick
+
+Build project fuzzer target::
 
-  $ python infra/helper.py build_image graphicsmagick
+  python infra/helper.py build_fuzzers --sanitizer <address/memory/undefined> \
+    --architecture <x86_64/i386> graphicsmagick
+
+  python infra/helper.py build_fuzzers --sanitizer address --architecture x86_64 graphicsmagick
 
-  $ python infra/helper.py build_fuzzers --sanitizer <address/memory/undefined> --architecture <x86_64/i386> graphicsmagick
+Reproduce using local source checkout (mount local sources into the running container)::
+
+  python infra/helper.py build_fuzzers \
+    --sanitizer <address/memory/undefined> graphicsmagick <source_path>
+
+  python infra/helper.py build_fuzzers --sanitizer address --architecture x86_64 graphicsmagick <source_path>
+  python infra/helper.py reproduce graphicsmagick <fuzz_target_name> <testcase_path>
 
 Reproducing bugs::
 
-  $ python infra/helper.py reproduce $PROJECT_NAME <fuzz_target_name> <testcase_path>
+  $ python infra/helper.py reproduce graphicsmagick <fuzz_target_name> <testcase_path>
+
+Check the build (this can take very long!)::
+
+  python infra/helper.py build_fuzzers --sanitizer <address/memory/undefined> \
+    --engine <libfuzzer/afl/honggfuzz/centipede> --architecture <x86_64/i386> graphicsmagick
+
+  python infra/helper.py check_build  --sanitizer <address/memory/undefined> \
+    --engine <libfuzzer/afl/honggfuzz/centipede> --architecture <x86_64/i386> graphicsmagick \
+    <fuzz_target_name>
+
+Get a shell into the container and compile::
+
+  python infra/helper.py shell --sanitizer address --architecture x86_64 graphicsmagick
+  compile 2>&1 | tee build.log
+
+Copy fuzzing build script into running container (given simultaneous shell session)::
+
+  docker cp fuzzing/oss-fuzz-build.sh $(docker ps -lq):/src/graphicsmagick/fuzzing/oss-fuzz-build.sh
+
+  Then use 'compile 2>&1 | tee build.log'.  This executes
+  /src/build.sh while in the initial "/src/graphicsmagick" directory
+  but does some other things as well.
diff -r c7bd6398ff60 -r bdf424d91f42 fuzzing/oss-fuzz-build.sh
--- a/fuzzing/oss-fuzz-build.sh	Thu Nov 14 17:40:00 2024 -0600
+++ b/fuzzing/oss-fuzz-build.sh	Sun Nov 17 16:34:49 2024 -0600
@@ -3,24 +3,6 @@
 # This shell script is intended to be run from OSS-Fuzz's build
 # environment. We intend to eventually refactor it to be easy to run
 # locally.
-
-# Useful OSS-Fuzz URLs:
-#
-# GM build status:
-#
-#   https://oss-fuzz-build-logs.storage.googleapis.com/index.html#graphicsmagick
-#
-# GM open issues:
-#
-#   https://issues.oss-fuzz.com/savedsearches/6886196
-#
-# OSS-Fuzz usage documentation:
-#
-#   https://google.github.io/oss-fuzz/
-#
-# OSS-Fuzz code master source tree:
-#
-#   https://github.com/google/oss-fuzz/tree/master
 #
 # For local testing of fuzzing/oss-fuzz-build.sh in 'compile' mode do:
 #
@@ -28,6 +10,7 @@
 # (e.g. '04a46e46f7af'). Can also check the output of 'docker ps -lq'.
 #
 # Then do:
+#
 # ~/src/GM% docker cp fuzzing/oss-fuzz-build.sh 04a46e46f7af:/src/graphicsmagick/fuzzing/oss-fuzz-build.sh
 #
 # or maybe"
@@ -388,10 +371,21 @@
     # PKG_CONFIG_PATH=/work/lib/pkgconfig:/usr/lib/pkgconfig pkg-config --static x265 --libs
     #    -L/work/lib -lx265 -lc++ -lm -lrt -lm -ldl -lgcc_s -lgcc -lgcc_s -lgcc -lrt -ldl
     # include(Version) # determine X265_VERSION and X265_LATEST_TAG
+    #
+
+    # The source for this is in source/x265.pc.in
     if $enable_x265
        then
            libx265="$SRC/x265"
            libx265_build="${libx265}/build/linux"
+
+           # If source/cmake/Version.cmake detects that the source
+           # code is managed by git, it fails to build or install the
+           # x265.pc file that libheif demands!
+           if [ -d "${libx265}/.git" ]
+           then
+               mv -f "${libx265}/.git" "${libx265}/.git-moved"
+           fi
            if [ -d "${libx265_build}" ]
            then
                pushd "${libx265_build}"
@@ -407,6 +401,7 @@
                      -DCMAKE_VERBOSE_MAKEFILE:BOOL=TRUE \
                      -DENABLE_ASSEMBLY:BOOL=OFF \
                      -DENABLE_SHARED:STRING=off \
+                     -DX265_LATEST_TAG=TRUE \
                      ../../source
                make clean
                make -j$(nproc) x265-static
@@ -415,6 +410,11 @@
            else
                printf "=== Skipping missing ${libx265_build}! ===\n"
            fi
+           # Restore original git directory
+           if [ -d "${libx265}/.git-moved" ]
+           then
+               mv -f "${libx265}/.git-moved" "${libx265}/.git"
+           fi
     fi
 
     # Build libde265 (a C++ library)
diff -r c7bd6398ff60 -r bdf424d91f42 magick/version.h
--- a/magick/version.h	Thu Nov 14 17:40:00 2024 -0600
+++ b/magick/version.h	Sun Nov 17 16:34:49 2024 -0600
@@ -38,8 +38,8 @@
 #define MagickLibVersion  0x282502
 #define MagickLibVersionText  "1.4"
 #define MagickLibVersionNumber 28,25,2
-#define MagickChangeDate   "20241114"
-#define MagickReleaseDate  "snapshot-20241114"
+#define MagickChangeDate   "20241117"
+#define MagickReleaseDate  "snapshot-20241117"
 
 /*
   The MagickLibInterfaceNewest and MagickLibInterfaceOldest defines
diff -r c7bd6398ff60 -r bdf424d91f42 www/ChangeLog.html
--- a/www/ChangeLog.html	Thu Nov 14 17:40:00 2024 -0600
+++ b/www/ChangeLog.html	Sun Nov 17 16:34:49 2024 -0600
@@ -38,10 +38,18 @@
 
 <main id="graphicsmagick-changelog">
 <h1 class="title">GraphicsMagick ChangeLog</h1>
+<p>2024-11-17  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
+<blockquote>
+<ul class="simple">
+<li><p>fuzzing/README.txt: Add more fuzzing notes.</p></li>
+<li><p>fuzzing/oss-fuzz-build.sh: Add a hack so that libx265 installs
+x265.pc.</p></li>
+</ul>
+</blockquote>
 <p>2024-11-14  Bob Friesenhahn  &lt;<a class="reference external" href="mailto:bfriesen&#37;&#52;&#48;simple&#46;dallas&#46;tx&#46;us">bfriesen<span>&#64;</span>simple<span>&#46;</span>dallas<span>&#46;</span>tx<span>&#46;</span>us</a>&gt;</p>
 <blockquote>
 <ul class="simple">
-<li><p>tests/rwfile.c: Fix appending file name.</p></li>
+<li><p>tests/rwfile.c: Fix appending file extension.</p></li>
 <li><p>coders/bmp.c (ReadBMPImage): Assure that opacity channel is
 initialized, even if matte is not true.  May help regarding
 GraphicsMagick discussion thread &quot;Opacity of whole Magick::image