Problem Description:
In the function wolfSSH_SFTP_SendReadPacket, when state->reqId != ssh->reqId is true (i.e., the request ID in the response does not match the expected request ID), the function only returns WS_FATAL_ERROR without clearing or discarding the remaining data in the response buffer. This may cause subsequent SFTP operations to parse the wrong data, leading to protocol desynchronization or errors.
Suggested Fix:
When detecting a request ID mismatch, the function should read and discard the remaining data of the current response to ensure the stream stays in sync, before returning the error.