Bugfix: erroring out on copying empty file; don't read if file size is 0.

pull/396/head
Anthony Hu 2022-03-24 15:36:55 -04:00
parent 17008c635e
commit 6c6b405f68
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;
}