From bb25181766e130da8bb89fb0805f1c36382e8572 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Thu, 4 Jun 2026 14:02:44 -0700 Subject: [PATCH] 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. --- src/wolfscp.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/wolfscp.c b/src/wolfscp.c index a1900ca9..62591596 100644 --- a/src/wolfscp.c +++ b/src/wolfscp.c @@ -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; + } } }