#!/bin/sh
# run.sh - run the DF-0790 harness in all modes (buggy + fixed).
# Each line exercises one crafted ATTRLIST shape. Modes:
#   clean      control: well-formed entry -> clean exit
#   loop       DF-0790 (A): reclen==0 -> ITERATION CAP (infinite loop in kernel)
#   null       DF-0790 (B): reclen>len  -> SIGSEGV (NULL deref panic in kernel)
#   oob_reclen bonus: reclen pushes next ptr past buffer -> SIGSEGV (OOB read)
# Adding "apply_fix" runs the proposed fixed walker, which rejects the
# malformed entries (rc=-1 == EINVAL in the kernel) instead of looping/faulting.
cd "$(dirname "$0")"
echo "=== BUGGY walk (kernel behaviour on default GENERIC #0) ==="
for m in clean loop null oob_reclen; do
    ./harness "$m" || true
done
echo
echo "=== FIXED walk (proposed fix rejects malformed entries) ==="
for m in clean loop null oob_reclen; do
    ./harness "$m" apply_fix || true
done
echo "RUN_EXIT=$?"
