From f128bea77991f8d2841438343798f9d3e8dc833e Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Mon, 22 Mar 2021 17:40:12 +0100 Subject: [PATCH] Fixes after reviewer's comments --- src/wolfscp.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/wolfscp.c b/src/wolfscp.c index c49a48a..61c18b5 100644 --- a/src/wolfscp.c +++ b/src/wolfscp.c @@ -1042,7 +1042,6 @@ static int GetScpTimestamp(WOLFSSH* ssh, byte* buf, word32 bufSz, return ret; } -#ifndef NO_FILESYSTEM /* checks for if directory is being renamed in command * * returns WS_SUCCESS on success @@ -1058,6 +1057,10 @@ static int ScpCheckForRename(WOLFSSH* ssh, int cmdSz) return WS_BUFFER_E; } + if (cmdSz + 4 > DEFAULT_SCP_MSG_SZ) { + return WS_BUFFER_E; + } + WSTRNCPY(buf, ssh->scpBasePath, cmdSz); buf[sz] = '\0'; WSTRNCAT(buf, "/..", sizeof("/..")); @@ -1118,15 +1121,14 @@ static int ScpCheckForRename(WOLFSSH* ssh, int cmdSz) return WS_SUCCESS; } -#endif /* helps with checking if the base path is a directory or file * returns WS_SUCCESS on success */ static int ParseBasePathHelper(WOLFSSH* ssh, int cmdSz) { int ret = 0; -#ifndef NO_FILESYSTEM ret = ScpCheckForRename(ssh, cmdSz); +#ifndef NO_FILESYSTEM { ScpSendCtx ctx;