From 1891546c01bb0536ed59dd4b40fe417c37c56fbf Mon Sep 17 00:00:00 2001 From: John Safranek Date: Thu, 24 Jan 2019 10:20:23 -0800 Subject: [PATCH] Back out a test case in Windows. Reconsolidated the checks into a single check. (wrt WriteFile) --- src/wolfsftp.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/wolfsftp.c b/src/wolfsftp.c index 6f43645..a48ddba 100644 --- a/src/wolfsftp.c +++ b/src/wolfsftp.c @@ -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;