[vlc-commits] [Git][videolan/vlc][3.0.x] avoid using wcscat_s

Steve Lhomme (@robUx4) gitlab at videolan.org
Wed Jun 12 07:48:32 UTC 2024



Steve Lhomme pushed to branch 3.0.x at VideoLAN / VLC


Commits:
ac6c3502 by Steve Lhomme at 2024-06-12T07:33:02+00:00
avoid using wcscat_s

It seems it's not available in Windows XP.
https://forum.videolan.org/viewtopic.php?f=14&t=164742&p=544877#p544877

_snwprintf was used before but we can't tell if the whole string was appended
properly.

- - - - -


2 changed files:

- bin/winvlc.c
- modules/text_renderer/freetype/fonts/win32.c


Changes:

=====================================
bin/winvlc.c
=====================================
@@ -217,10 +217,15 @@ int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
         if( S_OK != SHGetFolderPathW( NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE,
                     NULL, SHGFP_TYPE_CURRENT, path ) )
             fprintf( stderr, "Can't open the vlc conf PATH\n" );
-        else if ( !wcscat_s( path, MAX_PATH, L"\\vlc\\crashdump" ) )
+        else
         {
-            CheckCrashDump( path );
-            eh = InstallCrashHandler( path );
+            size_t pathlen = wcslen(path);
+            if ( pathlen + 1 + wcslen(L"\\vlc\\crashdump" ) <= MAX_PATH )
+            {
+                wcscpy( &path[pathlen], L"\\vlc\\crashdump" );
+                CheckCrashDump( path );
+                eh = InstallCrashHandler( path );
+            }
         }
     }
 #else


=====================================
modules/text_renderer/freetype/fonts/win32.c
=====================================
@@ -169,8 +169,9 @@ static char* GetWindowsFontPath()
     wchar_t wdir[MAX_PATH];
     if( S_OK != SHGetFolderPathW( NULL, CSIDL_FONTS, NULL, SHGFP_TYPE_CURRENT, wdir ) )
     {
-        GetWindowsDirectoryW( wdir, MAX_PATH );
-        wcscat_s( wdir, MAX_PATH, L"\\fonts" );
+        UINT wdirlen = GetWindowsDirectoryW( wdir, MAX_PATH );
+        if ( wdirlen + 1 + wcslen(L"\\fonts") <= MAX_PATH )
+            wcscpy( &wdir[wdirlen], L"\\fonts" );
     }
     return FromWide( wdir );
 }



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/ac6c3502f33dbe0ffb0d502a14b9f162343a9a61

-- 
This project does not include diff previews in email notifications.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/ac6c3502f33dbe0ffb0d502a14b9f162343a9a61
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