Back out a test case in Windows. Reconsolidated the checks into a single

check. (wrt WriteFile)
pull/134/head
John Safranek 2019-01-24 10:20:23 -08:00
parent a611c02211
commit 1891546c01
1 changed files with 4 additions and 9 deletions

View File

@ -6852,21 +6852,16 @@ int wolfSSH_SFTP_Get(WOLFSSH* ssh, char* from,
#else /* USE_WINDOWS_API */
{
DWORD bytesWritten = 0;
if (WriteFile(state->fileHandle, state->r, sz,
&bytesWritten, &state->offset) == 0) {
if ((WriteFile(state->fileHandle, state->r, sz,
&bytesWritten, &state->offset) == 0) ||
((DWORD)sz != bytesWritten))
{
WLOG(WS_LOG_SFTP, "Error writing to file");
ssh->error = WS_BAD_FILE_E;
ret = WS_FATAL_ERROR;
state->state = STATE_GET_CLEANUP;
break; /* either at end of file or error */
}
if ((DWORD)sz != bytesWritten) {
WLOG(WS_LOG_SFTP, "Error writing to file");
ssh->error = WS_MATCH_KEX_ALGO_E;
ret = WS_FATAL_ERROR;
state->state = STATE_GET_CLEANUP;
break; /* either at end of file or error */
}
}
#endif /* USE_WINDOWS_API */
state->gOfst += sz;