hamlib/tests/testctlbounds.sh
David Christle faefdac4ab
fix(rotctl): bound escaped command parsing
Stop parsing when an escape is missing or consumes no input, and count only successfully decoded bytes. This avoids the extra strtol call beyond the command terminator while preserving valid raw commands.
2026-07-29 10:39:38 -05:00

22 lines
687 B
Bash
Executable file

#!/bin/sh
set -eu
printf '\n' | ./rigctl -m 1 >/dev/null
printf '\n' | ./rotctl -m 1 >/dev/null
printf '\n' | ./ampctl -m 1 >/dev/null
./rigctl -m 1 3>/dev/null <&3 >/dev/null
./rotctl -m 1 3>/dev/null <&3 >/dev/null
./ampctl -m 1 3>/dev/null <&3 >/dev/null
./rigctl -m 1 w FA >/dev/null
./rigctl -m 1 -t -1 w 'x01 x02' >/dev/null
./rotctl -m 1 -t -1 w '\0x01\0x02' >/dev/null
./rotctl -m 1 -t -1 w '\' >/dev/null
binary_reply='\0x00\0xFF 2'
test "$(./rigctl -m 1 -t -1 w 'x00 xff')" = "$binary_reply"
test "$(./rigctl -m 1 -t -1 w '\0x00\0xff')" = "$binary_reply"
test "$(./rigctl -m 1 -t -1 w 'x00ff')" = "$binary_reply"
test "$(./rigctl -m 1 -t -1 w 'x00xff')" = "$binary_reply"