mirror of https://github.com/wolfSSL/wolfssh.git
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
parent
067187babe
commit
bb25181766
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue