summaryrefslogtreecommitdiffstats
path: root/bin/fuzzfiles
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
commit267c6f2ac71f92999e969232431ba04678e7437e (patch)
tree358c9467650e1d0a1d7227a21dac2e3d08b622b2 /bin/fuzzfiles
parentInitial commit. (diff)
downloadlibreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz
libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'bin/fuzzfiles')
-rwxr-xr-xbin/fuzzfiles41
1 files changed, 41 insertions, 0 deletions
diff --git a/bin/fuzzfiles b/bin/fuzzfiles
new file mode 100755
index 0000000000..ed0432d237
--- /dev/null
+++ b/bin/fuzzfiles
@@ -0,0 +1,41 @@
+#! /bin/bash
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+#check that zzuf is installed
+hash zzuf &> /dev/null
+if [ $? -eq 1 ];then
+ echo >&2 "zzuf not found. Please install and/or fix the PATH environment variable. Aborting"
+ exit -1
+fi
+
+#check that file(s) to fuzz are mentioned
+if [[ $# -eq 0 ]]; then
+ echo "Usage: fuzzfiles.sh <list of seed files to fuzz>"
+ echo "The generated fuzzed files will be output to the current working directory"
+ echo "The fuzzed files will be named XYZ-ratio-NNNN where:"
+ echo -e "\tXYZ: the original file name"
+ echo -e "\tratio: the fuzz ratio (what % of bytes were fuzzed)"
+ echo -e "\tNNNN: the mutation # for that file and ratio combo"
+ exit -1
+fi
+
+for file in $@; do
+ if [ -d $file ]; then
+ echo "$file is a directory. Only files are allowed"
+ elif [ -e $file ]; then
+ basename=${file##*/}
+ #Sequence from 0.001 to 0.5
+ for ratio in `seq -w 1 2 500 | sed -e 's/^/0./'`; do
+ echo "Fuzzing $file with ratio $ratio"
+ for i in {1..1000}; do
+ zzuf -r $ratio < $file > "$basename-$ratio-$i"
+ done #end of for i in {1..
+ done #end of for ratio in ...
+ fi #end if of file validity check
+done #end for file in $@