summaryrefslogtreecommitdiffstats
path: root/debian/tests/oversized-chunks
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 02:42:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-06 02:42:51 +0000
commitb324f452799a9aba5a1e9acc6833010c8635828e (patch)
treeccfd0a81e7daab4a2cd681a8161d3ae3748833dc /debian/tests/oversized-chunks
parentAdding upstream version 2.33.1. (diff)
downloadutil-linux-b324f452799a9aba5a1e9acc6833010c8635828e.tar.xz
util-linux-b324f452799a9aba5a1e9acc6833010c8635828e.zip
Adding debian version 2.33.1-0.1.debian/2.33.1-0.1debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'debian/tests/oversized-chunks')
-rwxr-xr-xdebian/tests/oversized-chunks69
1 files changed, 69 insertions, 0 deletions
diff --git a/debian/tests/oversized-chunks b/debian/tests/oversized-chunks
new file mode 100755
index 0000000..126ae86
--- /dev/null
+++ b/debian/tests/oversized-chunks
@@ -0,0 +1,69 @@
+#!/bin/bash
+#
+# This test was written in response to http://bugs.debian.org/785075 to
+# attempt to automatically catch when/if it happens again.
+# It seems something in the build toolchain is sometimes producing lots
+# of embedded zeroes in the executables.
+# For example in util-linux 2.26.2-2 the /sbin/fstrim was over 2MB in size
+# instead of normal ~ 40kB.
+#
+# Copyright (c) 2015, Andreas Henriksson <andreas@fatal.se>
+set -e
+set -u
+#set -x
+
+PACKAGES="util-linux bsdutils mount"
+# 10k should be large enough to not trigger false positives. Bump this
+# up if needed.
+CHUNKSIZELIMIT="10000"
+
+CURRENT=""
+LAST=""
+RET=0
+
+
+for FILE in $(dpkg -L $PACKAGES | egrep '/s?bin/') ; do
+
+if [ ! -e "$FILE" ]; then
+ #echo "E: target file '$FILE' not found." >&2
+ exit 1
+fi
+
+function chunk_size
+{
+ #echo "DEBUG: start => $1, stop => $2" >&2
+ SIZE=$(echo ibase=16 \; ${2^^} - ${1^^} | bc)
+ #echo "I: Calculated chunk size $SIZE ($2 - $1)" >&2
+ echo $SIZE
+}
+
+hd $FILE | grep -C1 '^\*' | while read -a CURRENT
+do
+ if [ "${CURRENT[0]}" = "--" ]; then
+ #echo "I: Skipping separator" >&2
+ continue
+ fi
+
+ if [ "${CURRENT[0]}" = "*" ]; then
+ #echo "I: Found chunk indicator." >&2
+ START="$LAST"
+ fi
+
+ if [ "$LAST" = "*" ]; then
+ #echo "I: Both start and stop should now be located." >&2
+ STOP="${CURRENT[0]}"
+ CHUNKSIZE=$(chunk_size "$START" "$STOP")
+ if [ "$CHUNKSIZE" -gt "$CHUNKSIZELIMIT" ]; then
+ echo "E: oversized chunk found in $FILE !"
+ ((RET++))
+ fi
+ fi
+
+ #echo "I: Yet another line processed." >&2
+ LAST="${CURRENT[0]}"
+
+done
+
+done
+
+exit $RET