adjust check for :/ and check on compare of file name

pull/271/head
Jacob Barthelmeh 2020-08-25 21:56:58 -06:00
parent 44d18953ed
commit 9a8b9e72c9
2 changed files with 6 additions and 6 deletions

View File

@ -161,7 +161,7 @@ static THREAD_RETURN WOLFSSH_THREAD server_worker(void* vArgs)
WMEMCPY(scpBufferSend.name, "test.txt", sizeof("test.txt")); WMEMCPY(scpBufferSend.name, "test.txt", sizeof("test.txt"));
scpBufferSend.nameSz = WSTRLEN("test.txt"); scpBufferSend.nameSz = WSTRLEN("test.txt");
scpBufferSend.buffer = fileTmp; scpBufferSend.buffer = fileTmp;
scpBufferSend.bufferSz = sizeof(fileTmp); scpBufferSend.bufferSz = sizeof(fileBuffer);
scpBufferSend.fileSz = sizeof(fileTmp); scpBufferSend.fileSz = sizeof(fileTmp);
scpBufferSend.mode = 0x1A4; scpBufferSend.mode = 0x1A4;
wolfSSH_SetScpSendCtx(threadCtx->ssh, (void*)&scpBufferSend); wolfSSH_SetScpSendCtx(threadCtx->ssh, (void*)&scpBufferSend);

View File

@ -1045,8 +1045,8 @@ static int ScpCheckForRename(WOLFSSH* ssh, int cmdSz)
} }
#else #else
/* allow placing file at base address ':/' */ /* allow placing file at base address ':/' */
if (sz == 1 && buf[0] == WS_DELIM) { if (WSTRLEN(buf) == 1 && buf[0] == WS_DELIM) {
idx--; idx--; /* no delimiter at base */
} }
#endif #endif
if (idx > cmdSz || idx > sz) { if (idx > cmdSz || idx > sz) {
@ -2598,7 +2598,7 @@ int wsScpSendCallback(WOLFSSH* ssh, int state, const char* peerRequest,
case WOLFSSH_SCP_SINGLE_FILE_REQUEST: case WOLFSSH_SCP_SINGLE_FILE_REQUEST:
if (sendBuffer->buffer == NULL) { if (sendBuffer->buffer == NULL) {
wolfSSH_SetScpErrorMsg(ssh, "no buffer to send"); WLOG(WS_LOG_DEBUG, scpState, "no buffer to send");
ret = WS_SCP_ABORT; ret = WS_SCP_ABORT;
break; break;
} }
@ -2614,7 +2614,7 @@ int wsScpSendCallback(WOLFSSH* ssh, int state, const char* peerRequest,
} }
if (WSTRLEN(fileName) != sendBuffer->nameSz || if (WSTRLEN(fileName) != sendBuffer->nameSz ||
WMEMCMP(sendBuffer->name, fileName, fileNameSz) != 0) { WMEMCMP(sendBuffer->name, fileName, sendBuffer->nameSz) != 0) {
wolfSSH_SetScpErrorMsg(ssh, "file name did not match"); wolfSSH_SetScpErrorMsg(ssh, "file name did not match");
ret = WS_SCP_ABORT; ret = WS_SCP_ABORT;
break; break;
@ -2672,7 +2672,7 @@ int wsScpSendCallback(WOLFSSH* ssh, int state, const char* peerRequest,
break; break;
default: default:
wolfSSH_SetScpErrorMsg(ssh, "bad state"); WLOG(WS_LOG_DEBUG, scpState, "bad state");
ret = WS_SCP_ABORT; ret = WS_SCP_ABORT;
} }
(void)fileOffset; (void)fileOffset;