[vlc-commits] [Git][videolan/vlc][master] 2 commits: win32: use the proper backslash in Windows pathes

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Wed Aug 10 08:09:04 UTC 2022



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
dec06aec by Steve Lhomme at 2022-08-10T07:53:49+00:00
win32: use the proper backslash in Windows pathes

Although a lot of Windows API's seem to be happy with the mixed slashes that
we use. The FindFirstFileExW() doesn't seem to like forward slash when allowing
long pathes to be found.

Fixes #27208

- - - - -
87b3e7c6 by Steve Lhomme at 2022-08-10T07:53:49+00:00
win32: remove forward slashes when opening long pathes

FindFirstFileExW() doesn't seem to like them. We should normally use proper
Windows pathes with vlc_opendir(). But this will make it safer if we don't.

- - - - -


2 changed files:

- src/win32/dirs.c
- src/win32/filesystem.c


Changes:

=====================================
src/win32/dirs.c
=====================================
@@ -98,7 +98,7 @@ char *config_GetSysPath(vlc_sysdir_t type, const char *filename)
         return dir;
 
     char *path;
-    if (unlikely(asprintf(&path, "%s/%s", dir, filename) == -1))
+    if (unlikely(asprintf(&path, "%s\\%s", dir, filename) == -1))
         path = NULL;
     free(dir);
     return path;


=====================================
src/win32/filesystem.c
=====================================
@@ -229,11 +229,20 @@ vlc_DIR *vlc_opendir (const char *dirname)
         free (p_dir);
         return NULL;
     }
+    if (!p_dir->u.insert_dot_dot)
+    {
+        // remove forward slashes from long pathes to please FindFirstFileExW
+        for (size_t i=0; p_dir->wildcard[i]!=L'\0';i++)
+        {
+            if (unlikely(p_dir->wildcard[i] == L'/'))
+                p_dir->wildcard[i] = L'\\';
+        }
+    }
 
     p_dir->fHandle = FindFirstFileExW(p_dir->wildcard, FindExInfoBasic,
                                       &p_dir->wdir, (FINDEX_SEARCH_OPS)0,
                                       NULL, FIND_FIRST_EX_LARGE_FETCH);
-    if (p_dir->fHandle ==  INVALID_HANDLE_VALUE)
+    if (p_dir->fHandle == INVALID_HANDLE_VALUE)
     {
         free(p_dir->wildcard);
         free(p_dir);



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/954b60ff45e28e0d833f107fb018c851cc7d249a...87b3e7c6930e7dd945d466d716192f1f9f627a09

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/954b60ff45e28e0d833f107fb018c851cc7d249a...87b3e7c6930e7dd945d466d716192f1f9f627a09
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list