Tighten SCP timestamp bounds check

Cleanup clang-tidy bugprone-inc-dec-in-conditions finding.

- ParseTimestamp: move ++idx out of the || conditions
  and tighten the bound from > bufSz to >= bufSz.
pull/1002/head
John Safranek 2026-06-04 14:02:44 -07:00
parent 067187babe
commit bb25181766
1 changed files with 11 additions and 4 deletions

View File

@ -1078,12 +1078,19 @@ static int GetScpTimestamp(WOLFSSH* ssh, byte* buf, word32 bufSz,
/* skip '0 ' */
if (ret == WS_SUCCESS) {
if (buf[idx] != '0' || ++idx > bufSz)
if (buf[idx] != '0') {
ret = WS_SCP_TIMESTAMP_E;
if (ret == WS_SUCCESS) {
if (buf[idx] != ' ' || ++idx > bufSz)
}
else {
idx++;
if (idx >= bufSz || buf[idx] != ' ') {
ret = WS_SCP_TIMESTAMP_E;
}
else {
idx++;
if (idx >= bufSz)
ret = WS_SCP_TIMESTAMP_E;
}
}
}