[vlc-devel] [PATCH 1/2] include: hash: add size to vlc_hash_FinishHex

Marvin Scholz epirat07 at gmail.com
Thu Apr 16 16:05:07 CEST 2020


---
 include/vlc_hash.h            |  2 +-
 modules/lua/libs/sd.c         |  2 +-
 modules/misc/audioscrobbler.c |  4 ++--
 modules/stream_out/stats.c    |  4 ++--
 src/input/input.c             |  2 +-
 src/network/http_auth.c       | 12 ++++++------
 src/preparser/art.c           |  2 +-
 src/test/md5.c                |  2 +-
 test/src/input/stream.c       |  2 +-
 9 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/include/vlc_hash.h b/include/vlc_hash.h
index 0a853d5ad3..1e7757ac58 100644
--- a/include/vlc_hash.h
+++ b/include/vlc_hash.h
@@ -57,7 +57,7 @@
  * \param[out]    output Output buffer to write the string to
  */
 #ifndef __cplusplus
-#define vlc_hash_FinishHex(ctx, output)                             \
+#define vlc_hash_FinishHex(ctx, output, size)                       \
     do {                                                            \
         char out_tmp[_Generic((ctx),                                \
             vlc_hash_md5_t *: VLC_HASH_MD5_DIGEST_SIZE)];           \
diff --git a/modules/lua/libs/sd.c b/modules/lua/libs/sd.c
index 7068ec8f90..fed74e197b 100644
--- a/modules/lua/libs/sd.c
+++ b/modules/lua/libs/sd.c
@@ -221,7 +221,7 @@ static input_item_t *vlclua_sd_create_item( services_discovery_t *p_sd,
             vlc_hash_md5_Update( &md5, s, strlen( s ) );
             free( s );
             char tmp[VLC_HASH_MD5_DIGEST_HEX_SIZE];
-            vlc_hash_FinishHex( &md5, tmp );
+            vlc_hash_FinishHex( &md5, tmp, sizeof(tmp) );
             input_item_AddInfo( p_input, "uid", "md5", "%s", tmp );
         }
     }
diff --git a/modules/misc/audioscrobbler.c b/modules/misc/audioscrobbler.c
index 8b25dd17d4..d8fc51df1b 100644
--- a/modules/misc/audioscrobbler.c
+++ b/modules/misc/audioscrobbler.c
@@ -499,7 +499,7 @@ static int Handshake(intf_thread_t *p_this)
     free(psz_password);
 
     char psz_password_md5[VLC_HASH_MD5_DIGEST_HEX_SIZE];
-    vlc_hash_FinishHex(&struct_md5, psz_password_md5);
+    vlc_hash_FinishHex(&struct_md5, psz_password_md5, sizeof(psz_password));
 
     snprintf(psz_timestamp, sizeof(psz_timestamp), "%"PRIu64,
               (uint64_t)timestamp);
@@ -512,7 +512,7 @@ static int Handshake(intf_thread_t *p_this)
     vlc_hash_md5_Update(&struct_md5, psz_password_md5, sizeof(psz_password_md5) - 1);
     vlc_hash_md5_Update(&struct_md5, psz_timestamp, strlen(psz_timestamp));
     char psz_auth_token[VLC_HASH_MD5_DIGEST_HEX_SIZE];
-    vlc_hash_FinishHex(&struct_md5, psz_auth_token);
+    vlc_hash_FinishHex(&struct_md5, psz_auth_token, sizeof(psz_auth_token));
 
     psz_scrobbler_url = var_InheritString(p_this, "scrobbler-url");
     if (!psz_scrobbler_url)
diff --git a/modules/stream_out/stats.c b/modules/stream_out/stats.c
index ea262f42e8..87a75609cc 100644
--- a/modules/stream_out/stats.c
+++ b/modules/stream_out/stats.c
@@ -95,7 +95,7 @@ static void Del( sout_stream_t *p_stream, void *_id )
     sout_stream_sys_t *p_sys = (sout_stream_sys_t *)p_stream->p_sys;
     sout_stream_id_sys_t *id = (sout_stream_id_sys_t *)_id;
 
-    vlc_hash_FinishHex( &id->hash, outputhash );
+    vlc_hash_FinishHex( &id->hash, outputhash, sizeof(outputhash) );
     unsigned int num,den;
     vlc_ureduce( &num, &den, id->track_duration, id->segment_number, 0 );
     msg_Dbg( p_stream, "%s: Removing track type:%s id:%d", p_sys->prefix, id->type, id->id );
@@ -123,7 +123,7 @@ static int Send( sout_stream_t *p_stream, void *_id, block_t *p_buffer )
         vlc_hash_md5_Init( &hash );
         vlc_hash_md5_Update( &hash, p_block->p_buffer, p_block->i_buffer );
         vlc_hash_md5_Update( &id->hash, p_block->p_buffer, p_block->i_buffer );
-        vlc_hash_FinishHex( &hash, outputhash );
+        vlc_hash_FinishHex( &hash, outputhash, sizeof(outputhash) );
 
         /* We could just set p_sys->output to stdout and remove user of msg_Dbg
          * if we don't need ability to output info to gui modules (like qt messages window
diff --git a/src/input/input.c b/src/input/input.c
index d6256fef47..36eaff626c 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -2550,7 +2550,7 @@ static input_source_t *InputSourceNew( const char *psz_mrl )
 
         vlc_hash_md5_Init( &md5 );
         vlc_hash_md5_Update( &md5, psz_mrl, strlen( psz_mrl ) );
-        vlc_hash_FinishHex( &md5, in->str_id );
+        vlc_hash_FinishHex( &md5, in->str_id, VLC_HASH_MD5_DIGEST_HEX_SIZE );
     }
 
     return in;
diff --git a/src/network/http_auth.c b/src/network/http_auth.c
index 4d49978ac9..bc1678d401 100644
--- a/src/network/http_auth.c
+++ b/src/network/http_auth.c
@@ -99,7 +99,7 @@ static char *GenerateCnonce()
     vlc_hash_md5_Init( &md5 );
     vlc_hash_md5_Update( &md5, ps_random, sizeof( ps_random ) );
 
-    vlc_hash_FinishHex( &md5, md5_hex );
+    vlc_hash_FinishHex( &md5, md5_hex, VLC_HASH_MD5_DIGEST_HEX_SIZE );
     return md5_hex;
 }
 
@@ -135,7 +135,7 @@ static char *AuthDigest( vlc_object_t *p_this, vlc_http_auth_t *p_auth,
         vlc_hash_md5_Update( &md5, p_auth->psz_realm, strlen( p_auth->psz_realm ) );
         vlc_hash_md5_Update( &md5, ":", 1 );
         vlc_hash_md5_Update( &md5, psz_password, strlen( psz_password ) );
-        vlc_hash_FinishHex( &md5, psz_HA1 );
+        vlc_hash_FinishHex( &md5, psz_HA1, sizeof(psz_HA1) );
 
         if ( p_auth->psz_algorithm &&
              strcmp( p_auth->psz_algorithm, "MD5-sess" ) == 0 )
@@ -146,7 +146,7 @@ static char *AuthDigest( vlc_object_t *p_this, vlc_http_auth_t *p_auth,
             vlc_hash_md5_Update( &md5, p_auth->psz_nonce, strlen( p_auth->psz_nonce ) );
             vlc_hash_md5_Update( &md5, ":", 1 );
             vlc_hash_md5_Update( &md5, p_auth->psz_cnonce, strlen( p_auth->psz_cnonce ) );
-            vlc_hash_FinishHex( &md5, psz_HA1 );
+            vlc_hash_FinishHex( &md5, psz_HA1, sizeof(psz_HA1) );
 
             p_auth->psz_HA1 = strdup( psz_HA1 );
             if ( p_auth->psz_HA1 == NULL )
@@ -168,12 +168,12 @@ static char *AuthDigest( vlc_object_t *p_this, vlc_http_auth_t *p_auth,
         vlc_hash_md5_Init( &ent );
         /* TODO: Support for "qop=auth-int" */
         vlc_hash_md5_Update( &ent, "", 0 );
-        vlc_hash_FinishHex( &ent, psz_ent );
+        vlc_hash_FinishHex( &ent, psz_ent, sizeof(psz_ent) );
         vlc_hash_md5_Update( &md5, ":", 1 );
         vlc_hash_md5_Update( &md5, psz_ent, sizeof(psz_ent) - 1 );
     }
 
-    vlc_hash_FinishHex( &md5, psz_HA2 );
+    vlc_hash_FinishHex( &md5, psz_HA2, sizeof(psz_HA2) );
 
     /* Request digest */
     vlc_hash_md5_Init( &md5 );
@@ -199,7 +199,7 @@ static char *AuthDigest( vlc_object_t *p_this, vlc_http_auth_t *p_auth,
     if (psz_result == NULL)
         return NULL;
 
-    vlc_hash_FinishHex( &md5, psz_result );
+    vlc_hash_FinishHex( &md5, psz_result, VLC_HASH_MD5_DIGEST_HEX_SIZE );
     return psz_result;
 }
 
diff --git a/src/preparser/art.c b/src/preparser/art.c
index b7f0d48411..027d88dafc 100644
--- a/src/preparser/art.c
+++ b/src/preparser/art.c
@@ -114,7 +114,7 @@ static char* ArtCacheGetDirPath( const char *psz_arturl, const char *psz_artist,
         vlc_hash_md5_Update( &md5, psz_arturl, strlen( psz_arturl ) );
         if( !strncmp( psz_arturl, "attachment://", 13 ) )
             vlc_hash_md5_Update( &md5, psz_title, strlen( psz_title ) );
-        vlc_hash_FinishHex( &md5, psz_arturl_sanitized );
+        vlc_hash_FinishHex( &md5, psz_arturl_sanitized, sizeof(psz_arturl_sanitized) );
         if( asprintf( &psz_dir, "%s" DIR_SEP "art" DIR_SEP "arturl" DIR_SEP
                       "%s", psz_cachedir, psz_arturl_sanitized ) == -1 )
             psz_dir = NULL;
diff --git a/src/test/md5.c b/src/test/md5.c
index c81e73b4d0..84f8f865a5 100644
--- a/src/test/md5.c
+++ b/src/test/md5.c
@@ -60,7 +60,7 @@ static void test_vlc_hash_md5()
         vlc_hash_md5_t md5;
         vlc_hash_md5_Init( &md5 );
         vlc_hash_md5_Update( &md5, md5_samples[i].psz_string, strlen( md5_samples[i].psz_string ) );
-        vlc_hash_FinishHex( &md5, psz_hash );
+        vlc_hash_FinishHex( &md5, psz_hash, sizeof(psz_hash) );
 
         if( strcmp( psz_hash, md5_samples[i].psz_md5 ) )
         {
diff --git a/test/src/input/stream.c b/test/src/input/stream.c
index 3b7ef19fc5..976a6c6181 100644
--- a/test/src/input/stream.c
+++ b/test/src/input/stream.c
@@ -317,7 +317,7 @@ test( struct reader **pp_readers, unsigned int i_readers, const char *psz_md5 )
     }
     if( psz_md5 != NULL )
     {
-        vlc_hash_FinishHex( &md5, psz_read_md5 );
+        vlc_hash_FinishHex( &md5, psz_read_md5, sizeof(psz_read_md5) );
         assert( strcmp( psz_read_md5, psz_md5 ) == 0 );
     }
 
-- 
2.24.1 (Apple Git-126)



More information about the vlc-devel mailing list