Commit f0ec1547 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

FYI, snprintf always nul-terminates

parent 79ca7b08
...@@ -2008,11 +2008,10 @@ static void CacheSave( vlc_object_t *p_this ) ...@@ -2008,11 +2008,10 @@ static void CacheSave( vlc_object_t *p_this )
} }
char psz_filename[sizeof(DIR_SEP) + 32 + strlen(psz_cachedir)]; char psz_filename[sizeof(DIR_SEP) + 32 + strlen(psz_cachedir)];
i_len = sizeof(DIR_SEP) + 32 + strlen(psz_cachedir);
config_CreateDir( p_this, psz_cachedir ); config_CreateDir( p_this, psz_cachedir );
snprintf( psz_filename, i_len, "%s"DIR_SEP"CACHEDIR.TAG", psz_cachedir ); snprintf( psz_filename, sizeof( psz_filename ),
psz_filename[i_len-1] = '\0'; "%s"DIR_SEP"CACHEDIR.TAG", psz_cachedir );
file = utf8_fopen( psz_filename, "wb" ); file = utf8_fopen( psz_filename, "wb" );
if( file ) if( file )
{ {
...@@ -2020,9 +2019,8 @@ static void CacheSave( vlc_object_t *p_this ) ...@@ -2020,9 +2019,8 @@ static void CacheSave( vlc_object_t *p_this )
fclose( file ); fclose( file );
} }
memset( psz_filename, 0, i_len ); snprintf( psz_filename, sizeof( psz_filename ),
snprintf( psz_filename, i_len, "%s"DIR_SEP"%s", psz_cachedir, CacheName() ); "%s"DIR_SEP"%s", psz_cachedir, CacheName() );
psz_filename[i_len-1] = '\0';
msg_Dbg( p_this, "saving plugins cache file %s", psz_filename ); msg_Dbg( p_this, "saving plugins cache file %s", psz_filename );
file = utf8_fopen( psz_filename, "wb" ); file = utf8_fopen( psz_filename, "wb" );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment