[vlc-commits] [Git][videolan/vlc][master] sftp: fix invalid free

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Mon Jan 3 15:50:02 UTC 2022



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


Commits:
271d3552 by Lyndon Brown at 2022-01-03T15:33:30+00:00
sftp: fix invalid free

`p_sys->psz_base_url` is `free()`'d by `Close()` as used in the error path.

use of a temporary variable, as requested in review, fixes the problem.

- - - - -


1 changed file:

- modules/access/sftp.c


Changes:

=====================================
modules/access/sftp.c
=====================================
@@ -475,6 +475,7 @@ static int Open( vlc_object_t* p_this )
     }
 
     /* No path, default to user Home */
+    char *base_url_tmp;
     if( !psz_path )
     {
         const size_t i_size = 1024;
@@ -500,11 +501,12 @@ static int Open( vlc_object_t* p_this )
         char *base = vlc_path2uri( psz_path, "sftp" );
         if( !base )
             goto error;
-        if( -1 == asprintf( &p_sys->psz_base_url, "sftp://%s%s", p_access->psz_location, base + 7 ) )
+        if( -1 == asprintf( &base_url_tmp, "sftp://%s%s", p_access->psz_location, base + 7 ) )
         {
             free( base );
             goto error;
         }
+        p_sys->psz_base_url = base_url_tmp;
         free( base );
     }
 
@@ -534,8 +536,9 @@ static int Open( vlc_object_t* p_this )
 
         if( !p_sys->psz_base_url )
         {
-            if( asprintf( &p_sys->psz_base_url, "sftp://%s", p_access->psz_location ) == -1 )
+            if( asprintf( &base_url_tmp, "sftp://%s", p_access->psz_location ) == -1 )
                 goto error;
+            p_sys->psz_base_url = base_url_tmp;
 
             /* trim trailing '/' */
             size_t len = strlen( p_sys->psz_base_url );



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

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/271d3552b7ad097d796bc431e946931abbe15658
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list