Fix integer comparison safety issues (6 HIGH priority)

Added parameter expansion with defaults to prevent comparison errors
on potentially empty variables:

- live-attack-monitor-v2.sh: IPSET_CREATE_EXIT, IPTABLES_EXIT
- live-attack-monitor.sh: IPSET_CREATE_EXIT, IPTABLES_EXIT
- malware-scanner.sh: START_EXIT
- email-diagnostics.sh: check_type, account_found

Pattern: Changed "$VAR" to "${VAR:-default}" in integer comparisons
to ensure safe comparisons even if variable is unexpectedly empty.
This commit is contained in:
cschantz
2026-01-02 17:23:02 -05:00
parent cd079bd7b6
commit 51b4dbde1e
4 changed files with 6 additions and 6 deletions
+2 -2
View File
@@ -93,7 +93,7 @@ if command -v ipset &>/dev/null; then
IPSET_CREATE_OUTPUT=$(ipset create "$IPSET_NAME" hash:ip timeout 3600 maxelem 65536 2>&1)
IPSET_CREATE_EXIT=$?
if [ $IPSET_CREATE_EXIT -eq 0 ]; then
if [ "${IPSET_CREATE_EXIT:-1}" -eq 0 ]; then
IPSET_AVAILABLE=1
IPSET_SUPPORTS_TIMEOUT=1
@@ -101,7 +101,7 @@ if command -v ipset &>/dev/null; then
IPTABLES_OUTPUT=$(iptables -I INPUT -m set --match-set "$IPSET_NAME" src -j DROP 2>&1)
IPTABLES_EXIT=$?
if [ $IPTABLES_EXIT -ne 0 ]; then
if [ "${IPTABLES_EXIT:-1}" -ne 0 ]; then
# iptables rule failed - clean up ipset and report error
ipset destroy "$IPSET_NAME" 2>/dev/null
IPSET_AVAILABLE=0