@@ -3276,10 +3276,6 @@ void* wolfSSH_GetChannelCloseCtx(WOLFSSH* ssh)
32763276#if (defined(WOLFSSH_SFTP ) || defined(WOLFSSH_SCP )) && \
32773277 !defined(NO_WOLFSSH_SERVER )
32783278
3279- #define DELIM "/\\"
3280- #define IS_DELIM (x ) ((x) == '/' || (x) == '\\')
3281- #define IS_WINPATH (x ,y ) ((x) > 1 && (y)[1] == ':')
3282-
32833279/*
32843280 * Paths starting with a slash are absolute, rooted at "/". Any path that
32853281 * doesn't have a starting slash is assumed to be relative to the default
@@ -3288,6 +3284,8 @@ void* wolfSSH_GetChannelCloseCtx(WOLFSSH* ssh)
32883284 * The path "/." is stripped out. The path "/.." strips out the previous
32893285 * path value. The root path, "/", is always present.
32903286 *
3287+ * Trailing delimiters are stripped, i.e /tmp/path/ becomes /tmp/path
3288+ *
32913289 * Example: "/home/fred/frob/frizz/../../../barney/bar/baz/./././../.."
32923290 * will return "/home/barney". "/../.." will return "/". "." will return
32933291 * the default path.
@@ -3319,7 +3317,8 @@ int wolfSSH_RealPath(const char* defaultPath, char* in,
33193317 inSz = (word32 )WSTRLEN (in );
33203318 out [0 ] = '/' ;
33213319 curSz = 1 ;
3322- if (inSz == 0 || (!IS_DELIM (in [0 ]) && !IS_WINPATH (inSz , in ))) {
3320+ if (inSz == 0 || (!WOLFSSH_SFTP_IS_DELIM (in [0 ]) &&
3321+ !WOLFSSH_SFTP_IS_WINPATH (inSz , in ))) {
33233322 if (defaultPath != NULL ) {
33243323 curSz = (word32 )WSTRLEN (defaultPath );
33253324 if (curSz >= outSz ) {
@@ -3330,9 +3329,9 @@ int wolfSSH_RealPath(const char* defaultPath, char* in,
33303329 }
33313330 out [curSz ] = 0 ;
33323331
3333- for (seg = WSTRTOK (in , DELIM , & tail );
3332+ for (seg = WSTRTOK (in , WOLFSSH_SFTP_DELIM , & tail );
33343333 seg ;
3335- seg = WSTRTOK (NULL , DELIM , & tail )) {
3334+ seg = WSTRTOK (NULL , WOLFSSH_SFTP_DELIM , & tail )) {
33363335 segSz = (word32 )WSTRLEN (seg );
33373336
33383337 /* Try to match "." */
0 commit comments