fix for uninitialized value and for base directory on nucleus port

pull/88/head
Jacob Barthelmeh 2018-08-07 18:42:15 -06:00
parent cea5d5664e
commit 53e14bd3c9
1 changed files with 7 additions and 0 deletions

View File

@ -1053,6 +1053,7 @@ static int ParseBasePathHelper(WOLFSSH* ssh, int cmdSz)
ScpSendCtx ctx; ScpSendCtx ctx;
int ret = WS_SUCCESS; int ret = WS_SUCCESS;
WMEMSET(&ctx, 0, sizeof(ScpSendCtx));
if (ScpPushDir(&ctx, ssh->scpBasePath, ssh->ctx->heap) != WS_SUCCESS) { if (ScpPushDir(&ctx, ssh->scpBasePath, ssh->ctx->heap) != WS_SUCCESS) {
/* case of file, not directory */ /* case of file, not directory */
char buf[cmdSz + 4]; char buf[cmdSz + 4];
@ -1069,6 +1070,12 @@ static int ParseBasePathHelper(WOLFSSH* ssh, int cmdSz)
clean_path(buf); clean_path(buf);
idx = (int)WSTRLEN(buf) + 1; /* +1 for delimiter */ idx = (int)WSTRLEN(buf) + 1; /* +1 for delimiter */
#ifdef WOLFSSL_NUCLEUS
/* no delimiter to skip in case of at base address */
if (idx == 4) { /* case of 4 for drive letter plus ":\" + 1 */
idx--;
}
#endif
if (idx > cmdSz || idx > sz) { if (idx > cmdSz || idx > sz) {
return WS_BUFFER_E; return WS_BUFFER_E;
} }