Merge pull request #396 from anhu/empty_file

Bugfix: erroring out on copying empty file
pull/399/head
David Garske 2022-03-24 13:29:55 -07:00 committed by GitHub
commit eae46da927
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -2454,11 +2454,13 @@ int wsScpSendCallback(WOLFSSH* ssh, int state, const char* peerRequest,
ret = ExtractFileName(peerRequest, fileName, fileNameSz);
if (ret == WS_SUCCESS && sendCtx != NULL && sendCtx->fp != NULL) {
ret = (word32)WFREAD(buf, 1, bufSz, sendCtx->fp);
if (ret == 0) { /* handle unexpected case */
ret = WS_EOF;
/* If it is an empty file, do not read. */
if (*totalFileSz != 0) {
ret = (word32)WFREAD(buf, 1, bufSz, sendCtx->fp);
if (ret == 0) { /* handle unexpected case */
ret = WS_EOF;
}
}
} else {
ret = WS_SCP_ABORT;
}