@@ -280,7 +280,7 @@ static bool smb_build_path(char *dest, size_t dest_size, const char *relative_pa
280280 if (!string_is_empty (settings -> arrays .smb_client_subdir ))
281281 {
282282 strlcpy (temp_path , settings -> arrays .smb_client_subdir , sizeof (temp_path ));
283- if (temp_path [strlen (temp_path ) - 1 ] != '/' )
283+ if (temp_path [0 ] != '\0' && temp_path [ strlen (temp_path ) - 1 ] != '/' )
284284 strlcat (temp_path , "/" , sizeof (temp_path ));
285285 }
286286
@@ -331,7 +331,7 @@ bool retro_vfs_file_open_smb(libretro_vfs_implementation_file *stream,
331331
332332 /* Strip leading slash ONLY for non-empty subpaths */
333333 if (full_path [0 ] == '/' && full_path [1 ] != '\0' )
334- strlcpy (full_path , full_path + 1 , sizeof (full_path ));
334+ memmove (full_path , full_path + 1 , strlen (full_path ));
335335
336336 /* Do not treat empty string as a file path */
337337 if (full_path [0 ] == '\0' )
@@ -527,7 +527,7 @@ smb_dir_handle* retro_vfs_opendir_smb(const char *path, bool include_hidden)
527527 /* If we have a leading slash AND a non-empty remainder, strip it.
528528 * Do NOT convert empty string to "." — root listing worked with "" */
529529 if (full_path [0 ] == '/' && full_path [1 ] != '\0' )
530- strlcpy (full_path , full_path + 1 , sizeof (full_path ));
530+ memmove (full_path , full_path + 1 , strlen (full_path ));
531531
532532 smb_context = get_smb_context ();
533533 if (!smb_context )
@@ -617,7 +617,7 @@ int retro_vfs_stat_smb(const char *path, int32_t *size)
617617
618618 /* Strip leading slash safely (preserve NULL terminator) */
619619 if (rel_path [0 ] == '/' && rel_path [1 ] != '\0' )
620- strlcpy (rel_path , rel_path + 1 , sizeof (rel_path ));
620+ memmove (rel_path , rel_path + 1 , strlen (rel_path ));
621621
622622 smb_context = get_smb_context ();
623623 if (!smb_context )
0 commit comments