@@ -1138,7 +1138,7 @@ static int ScpCheckForRename(WOLFSSH* ssh, int cmdSz)
11381138 buf [sz ] = '\0' ;
11391139 WSTRNCAT (buf , "/.." , DEFAULT_SCP_MSG_SZ );
11401140
1141- idx = wolfSSH_CleanPath (ssh , buf );
1141+ idx = wolfSSH_CleanPath (ssh , buf , DEFAULT_SCP_MSG_SZ );
11421142 if (idx < 0 ) {
11431143 return WS_FATAL_ERROR ;
11441144 }
@@ -1304,7 +1304,8 @@ int ParseScpCommand(WOLFSSH* ssh)
13041304 WMEMCPY (ssh -> scpBasePathDynamic , cmd + idx ,
13051305 cmdSz - idx );
13061306 if (wolfSSH_CleanPath (ssh ,
1307- ssh -> scpBasePathDynamic ) < 0 ) {
1307+ ssh -> scpBasePathDynamic ,
1308+ ssh -> scpBasePathSz ) < 0 ) {
13081309 ret = WS_FATAL_ERROR ;
13091310 }
13101311 else {
@@ -1330,7 +1331,8 @@ int ParseScpCommand(WOLFSSH* ssh)
13301331 WMEMCPY (ssh -> scpBasePathDynamic , cmd + idx ,
13311332 cmdSz - idx );
13321333 if (wolfSSH_CleanPath (ssh ,
1333- ssh -> scpBasePathDynamic ) < 0 )
1334+ ssh -> scpBasePathDynamic ,
1335+ ssh -> scpBasePathSz ) < 0 )
13341336 ret = WS_FATAL_ERROR ;
13351337 }
13361338 break ;
@@ -1972,7 +1974,7 @@ int wsScpRecvCallback(WOLFSSH* ssh, int state, const char* basePath,
19721974 {
19731975 DSTAT stat ;
19741976
1975- wolfSSH_CleanPath (ssh , (char * )basePath );
1977+ wolfSSH_CleanPath (ssh , (char * )basePath , WOLFSSH_MAX_FILENAME );
19761978 /* make sure is directory */
19771979 if ((ret = NU_Get_First (& stat , basePath )) != NU_SUCCESS ) {
19781980 /* if back to root directory i.e. A:/ then handle case
@@ -2020,7 +2022,7 @@ int wsScpRecvCallback(WOLFSSH* ssh, int state, const char* basePath,
20202022 WSTRNCAT (abslut , (char * )basePath , WOLFSSH_MAX_FILENAME );
20212023 WSTRNCAT (abslut , "/" , WOLFSSH_MAX_FILENAME );
20222024 WSTRNCAT (abslut , fileName , WOLFSSH_MAX_FILENAME );
2023- wolfSSH_CleanPath (ssh , abslut );
2025+ wolfSSH_CleanPath (ssh , abslut , WOLFSSH_MAX_FILENAME );
20242026 if (WFOPEN (ssh -> fs , & fp , abslut , "wb" ) != 0 ) {
20252027 #else
20262028 if (WFOPEN (ssh -> fs , & fp , fileName , "wb" ) != 0 ) {
@@ -2106,7 +2108,7 @@ int wsScpRecvCallback(WOLFSSH* ssh, int state, const char* basePath,
21062108 WSTRNCAT (abslut , (char * )basePath , WOLFSSH_MAX_FILENAME );
21072109 WSTRNCAT (abslut , "/" , WOLFSSH_MAX_FILENAME );
21082110 WSTRNCAT (abslut , fileName , WOLFSSH_MAX_FILENAME );
2109- wolfSSH_CleanPath (ssh , abslut );
2111+ wolfSSH_CleanPath (ssh , abslut , WOLFSSH_MAX_FILENAME );
21102112 if (WMKDIR (ssh -> fs , abslut , fileMode ) != 0 ) {
21112113 /* check if directory already exists */
21122114 if (NU_Make_Dir (abslut ) != NUF_EXIST ) {
@@ -2134,7 +2136,7 @@ int wsScpRecvCallback(WOLFSSH* ssh, int state, const char* basePath,
21342136 #ifdef WOLFSSL_NUCLEUS
21352137 WSTRNCAT ((char * )basePath , "/" , sizeof ("/" ));
21362138 WSTRNCAT ((char * )basePath , fileName , WOLFSSH_MAX_FILENAME );
2137- wolfSSH_CleanPath (ssh , (char * )basePath );
2139+ wolfSSH_CleanPath (ssh , (char * )basePath , WOLFSSH_MAX_FILENAME );
21382140 #else
21392141 if (WCHDIR (ssh -> fs , fileName ) != 0 ) {
21402142 WLOG (WS_LOG_ERROR ,
@@ -2151,7 +2153,7 @@ int wsScpRecvCallback(WOLFSSH* ssh, int state, const char* basePath,
21512153 /* cd out of directory */
21522154 #ifdef WOLFSSL_NUCLEUS
21532155 WSTRNCAT ((char * )basePath , "/.." , WOLFSSH_MAX_FILENAME - 1 );
2154- wolfSSH_CleanPath (ssh , (char * )basePath );
2156+ wolfSSH_CleanPath (ssh , (char * )basePath , WOLFSSH_MAX_FILENAME );
21552157 #else
21562158 if (WCHDIR (ssh -> fs , ".." ) != 0 ) {
21572159 WLOG (WS_LOG_ERROR ,
@@ -2564,7 +2566,7 @@ static int ScpProcessEntry(WOLFSSH* ssh, char* fileName, word64* mTime,
25642566 DEFAULT_SCP_FILE_NAME_SZ );
25652567 WSTRNCPY (fileName , sendCtx -> currentDir -> dir .lfname ,
25662568 DEFAULT_SCP_FILE_NAME_SZ );
2567- if (wolfSSH_CleanPath (ssh , filePath ) < 0 ) {
2569+ if (wolfSSH_CleanPath (ssh , filePath , DEFAULT_SCP_FILE_NAME_SZ ) < 0 ) {
25682570 ret = WS_SCP_ABORT ;
25692571 }
25702572 #elif defined(USE_WINDOWS_API )
0 commit comments