From 42c1df5e2d7f24183635d2daf2a0045e99c5ceb8 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Mon, 20 Nov 2023 14:26:44 +0100 Subject: [PATCH] test: add simple test case for invalid userspace log records --- test/units/testsuite-70.pcrlock.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/units/testsuite-70.pcrlock.sh b/test/units/testsuite-70.pcrlock.sh index 415bfa8ff4c..46060c1dc3e 100755 --- a/test/units/testsuite-70.pcrlock.sh +++ b/test/units/testsuite-70.pcrlock.sh @@ -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" -- 2.47.3