]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: add simple test case for invalid userspace log records 30104/head
authorLuca Boccassi <bluca@debian.org>
Mon, 20 Nov 2023 13:26:44 +0000 (14:26 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 20 Nov 2023 13:27:38 +0000 (14:27 +0100)
test/units/testsuite-70.pcrlock.sh

index 415bfa8ff4cd26b367497bc8e4a9ce4b2439c77c..46060c1dc3eaf6c1d0d4fc700b6e2a7c4689e170 100755 (executable)
@@ -41,6 +41,15 @@ PCRS="1+2+3+4+5+16"
 # (as the PCR values simply won't match the log).
 rm -f /run/log/systemd/tpm2-measure.log
 
+# Ensure a truncated log doesn't crash pcrlock
+echo -n -e \\x1e >/tmp/borked
+set +e
+SYSTEMD_MEASURE_LOG_USERSPACE=/tmp/borked "$SD_PCRLOCK" cel --no-pager --json=pretty
+ret=$?
+set -e
+# If it crashes the exit code will be 149
+test $ret -eq 1
+
 SYSTEMD_COLORS=256 "$SD_PCRLOCK"
 "$SD_PCRLOCK" cel --no-pager --json=pretty
 "$SD_PCRLOCK" log --pcr="$PCRS"