DF-4683 / fix_validate.sh
#!/bin/sh # DF-4680 / DF-4681 / DF-4682 / DF-4683 fix validation (guest). # Applies each fix.diff to a copy of the pristine guest ar2317.c, # re-extracts the (patched) function bodies verbatim, rebuilds the # harness against them and re-runs the affected mode(s). # Success criteria: # fixA (DF-4680): mode 1 -> NO overflow past pcdacTable[128] # fixB (DF-4681): mode 2 -> ret=0, sentinel minPower, no 0x5A5A # fixC (DF-4682): mode 3 -> completes without the wild SIGSEGV # fixD (DF-4683): mode 5 -> completes with fixD alone; # mode 4 -> completes with fixB+fixD (fixD skips the # inverted gain => zero gains remain => fixB's early # return covers that residual path) set -e cd /root/df2317 extract() { awk ' !f && /^GetLowerUpperIndex\(int16_t v/ { print prev; f=1 } f { print; if ($0 ~ /^#undef VpdTable_I/) { getline; print; exit } } { prev = $0 } ' "$1" > ar2317_extracted.inc wc -l ar2317_extracted.inc } run_fixed() { cc -O2 -Wall -Wno-pointer-sign -o ar2317_harness_fixed ar2317_harness.c echo FIXED_BUILD_OK } echo "===== fixA (DF-4680 kk guards) =====" cp ar2317_src.c ar2317_fixed.c patch -p1 ar2317_fixed.c < fixA.diff echo PATCHES_APPLIED extract ar2317_fixed.c run_fixed echo "--- PATCHED mode 1 (expect: NO overflow) ---" ./ar2317_harness_fixed 1 || echo "exit=$? (1 == no overflow detected = FIXED)" echo "===== fixB (DF-4681 zero-gain early return) =====" cp ar2317_src.c ar2317_fixed.c patch -p1 ar2317_fixed.c < fixB.diff echo PATCHES_APPLIED extract ar2317_fixed.c run_fixed echo "--- PATCHED mode 2 (expect: ret=0, no 0x5A5A propagation, sentinel minPower) ---" ./ar2317_harness_fixed 2 || echo "exit=$?" echo "===== fixC (DF-4682 flat-curve guards) =====" cp ar2317_src.c ar2317_fixed.c patch -p1 ar2317_fixed.c < fixC.diff echo PATCHES_APPLIED extract ar2317_fixed.c run_fixed echo "--- PATCHED mode 3 (expect: completes, no SIGSEGV at wild address) ---" ./ar2317_harness_fixed 3 || echo "exit=$? (1 == no fault = FIXED)" echo "===== fixD (DF-4683 span clamp) =====" cp ar2317_src.c ar2317_fixed.c patch -p1 ar2317_fixed.c < fixD.diff echo PATCHES_APPLIED extract ar2317_fixed.c run_fixed echo "--- PATCHED mode 5 with fixD only (expect: completes) ---" ./ar2317_harness_fixed 5 || echo "exit=$? (1 == no fault = FIXED)" echo "===== fixD + fixB (DF-4683 mode 4 residual zero-gain path) =====" cp ar2317_src.c ar2317_fixed.c patch -p1 ar2317_fixed.c < fixD.diff patch -p1 ar2317_fixed.c < fixB.diff echo PATCHES_APPLIED extract ar2317_fixed.c run_fixed echo "--- PATCHED mode 4 with fixB+fixD (expect: completes) ---" ./ar2317_harness_fixed 4 || echo "exit=$? (1 == no fault = FIXED)" echo "--- PATCHED mode 1/2/3 sanity with fixB+fixD ---" ./ar2317_harness_fixed 1 || true ./ar2317_harness_fixed 2 || true ./ar2317_harness_fixed 3 || true |