fix: sanitize _mtime with tr to prevent ash arithmetic crash on Synology
stat output can include non-numeric chars on some RT2600ac firmware versions, causing 0 to fail. Strip with tr -cd '0-9' before arithmetic. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -207,6 +207,7 @@ _detect_wan_roles() {
|
||||
_aiwanbal_available() {
|
||||
[ -d "$AIWANBAL_DIR" ] || return 1
|
||||
_mtime=$(stat -c %Y "${AIWANBAL_DIR}/wan1_score_avg" 2>/dev/null || stat -f %m "${AIWANBAL_DIR}/wan1_score_avg" 2>/dev/null)
|
||||
_mtime=$(printf '%s' "$_mtime" | tr -cd '0-9')
|
||||
[ -n "$_mtime" ] || return 1
|
||||
_now=$(date +%s)
|
||||
_age=$(( _now - _mtime ))
|
||||
@@ -415,6 +416,7 @@ _cached_speedtest() {
|
||||
_f="${STATE_DIR}/speedtest-result-${_iface}"
|
||||
[ -f "$_f" ] || return 1
|
||||
_mtime=$(stat -c %Y "$_f" 2>/dev/null || stat -f %m "$_f" 2>/dev/null)
|
||||
_mtime=$(printf '%s' "$_mtime" | tr -cd '0-9')
|
||||
[ -n "$_mtime" ] || return 1
|
||||
_st_now=$(date +%s)
|
||||
_age=$(( _st_now - _mtime ))
|
||||
|
||||
Reference in New Issue
Block a user