@@ -92,7 +92,7 @@ char* redirect_path_full(const char* pathname, int check_parent, int only_if_abs
9292 if (only_if_absolute && pathname [0 ] != '/' ) {
9393 return strdup (pathname );
9494 }
95-
95+
9696 char * appdir_env = getenv (APPRUN_ENV_APPDIR );
9797 if (appdir_env == NULL ) {
9898 return strdup (pathname );
@@ -110,9 +110,14 @@ char* redirect_path_full(const char* pathname, int check_parent, int only_if_abs
110110 if (strncmp (pathname , apprun_path_mappings [i ]-> path , strlen (apprun_path_mappings [i ]-> path )) == 0 ) {
111111 memset (redirected_pathname , 0 , PATH_MAX );
112112
113- strcat (redirected_pathname , appdir_env );
114- strcat (redirected_pathname , apprun_path_mappings [i ]-> mapping );
115- strcat (redirected_pathname , pathname + strlen (apprun_path_mappings [i ]-> path ));
113+ const char * mapping = apprun_path_mappings [i ]-> mapping ;
114+ const char * path_postfix = pathname + strlen (apprun_path_mappings [i ]-> path );
115+
116+ strcat (redirected_pathname , mapping );
117+ if (mapping [strlen (mapping ) - 1 ] != '/' && path_postfix [0 ] != '/' )
118+ strcat (redirected_pathname , "/" );
119+
120+ strcat (redirected_pathname , path_postfix );
116121
117122 ret = _access (redirected_pathname , F_OK );
118123 if (ret == 0 || errno == ENOTDIR ) { // ENOTDIR is OK because it exists at least
0 commit comments