Skip to content

Commit ddd15cb

Browse files
authored
Merge pull request #369 from JacobBarthelmeh/sftp
2 parents cde04a5 + eda1587 commit ddd15cb

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

src/wolfsftp.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)