@@ -6267,6 +6267,11 @@ static int SFTP_STAT(WOLFSSH* ssh, char* dir, WS_SFTP_FILEATRB* atr, byte type)
62676267 return WS_FATAL_ERROR ;
62686268 }
62696269 WLOG (WS_LOG_SFTP , "SFTP LSTAT STATE: PARSE_REPLY" );
6270+
6271+ /* after doing a 'read' the buffers index is now set to just
6272+ * after the data that has been read, rewind here to set the
6273+ * index to the beginning of data read and then process it */
6274+ wolfSSH_SFTP_buffer_rewind (& state -> buffer );
62706275 if (state -> type == WOLFSSH_FTP_ATTRS ) {
62716276 localIdx = wolfSSH_SFTP_buffer_idx (& state -> buffer );
62726277 ret = SFTP_ParseAtributes_buffer (ssh , atr ,
@@ -6284,7 +6289,6 @@ static int SFTP_STAT(WOLFSSH* ssh, char* dir, WS_SFTP_FILEATRB* atr, byte type)
62846289 }
62856290 }
62866291 else if (state -> type == WOLFSSH_FTP_STATUS ) {
6287- wolfSSH_SFTP_buffer_rewind (& state -> buffer );
62886292 ret = wolfSSH_SFTP_DoStatus (ssh , state -> reqId ,
62896293 & state -> buffer );
62906294 if (ret != WOLFSSH_FTP_OK ) {
@@ -6429,6 +6433,10 @@ int wolfSSH_SFTP_SetSTAT(WOLFSSH* ssh, char* dir, WS_SFTP_FILEATRB* atr)
64296433 }
64306434 return WS_FATAL_ERROR ;
64316435 }
6436+
6437+ /* free up the buffer used to send data so that a new fresh buffer
6438+ * can be created when next reading the attribute packet header */
6439+ wolfSSH_SFTP_buffer_free (ssh , & state -> buffer );
64326440 state -> state = STATE_SET_ATR_GET ;
64336441 NO_BREAK ;
64346442
0 commit comments