Files
httrack/tests/53_local-proxytrack-cache-corrupt.test
Xavier Roche 2fccb17058 Teardown must not decide a test's verdict
Under set -e a failing command in an EXIT trap becomes the script's exit
status, so a cleanup hiccup fails a test whose assertions all passed. Run
teardown with errexit off, on EXIT only: sharing set +e with the signal
traps would leave errexit off for the rest of a signalled run, where a
torn-down test could still report success. A failing teardown command
still prints its own diagnostic, so nothing is silenced.

The return 0 that three cleanup() bodies ended with never protected
anything: errexit fires at the failing command before it is reached.

Closes #773

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Xavier Roche <xroche@gmail.com>
2026-07-27 10:39:24 +02:00

22 lines
708 B
Bash

#!/bin/bash
# A corrupt proxytrack .ndx must not overflow the fixed cache-read buffers. The
# sanitizer CI build turns any regression here into a hard stack/heap overflow.
set -euo pipefail
dir=$(mktemp -d)
trap 'set +e; rm -rf "$dir"' EXIT
# The first length-prefixed field declares far more than firstline[256] holds;
# cache_brstr must clamp the copy to the destination, not the declared length.
{
printf '4000\n'
head -c 4000 /dev/zero | tr '\0' 'A'
} >"$dir/foo.ndx"
: >"$dir/foo.dat" # cache_brstr runs only when the sibling .dat opens
proxytrack --convert "$dir/out.arc" "$dir/foo.ndx" >/dev/null 2>&1 || {
echo "FAIL: proxytrack crashed/errored on a corrupt cache index"
exit 1
}