X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmisc%2Fupdate_crypto.c;h=ccf5c5770671ff94273f76e0862fd9b316e1bf3f;hb=eed0e7361a853185b673446c0b2adb58e99b3cd7;hp=fa557a832c12a8c5c575fb4687ea669a8ac91c8a;hpb=1c378b2dd1f4428baffd436a28bc8aa92dc9b5fa;p=vlc diff --git a/src/misc/update_crypto.c b/src/misc/update_crypto.c index fa557a832c..ccf5c57706 100644 --- a/src/misc/update_crypto.c +++ b/src/misc/update_crypto.c @@ -34,6 +34,8 @@ # include "config.h" #endif +#ifdef UPDATE_CHECK + #include #include @@ -651,34 +653,6 @@ error: } -/* hash a text - * * provided as a buffer (\0 terminated) - * * with "\r\n" line endings if it's a text signature, else use UNIX line - * * endings - */ -static int hash_from_string( const char *psz_string, gcry_md_hd_t hd, - bool text_signature ) -{ - while( *psz_string ) - { - size_t i_len = strcspn( psz_string, "\r\n" ); - if( !i_len ) - break; - - gcry_md_write( hd, psz_string, i_len ); - if( text_signature ) - gcry_md_putc( hd, '\r' ); - gcry_md_putc( hd, '\n' ); - - psz_string += i_len; - while( *psz_string == '\r' || *psz_string == '\n' ) - psz_string++; - } - - return 0; -} - - /* hash a binary file */ static int hash_from_binary_file( const char *psz_file, gcry_md_hd_t hd ) { @@ -752,11 +726,23 @@ uint8_t *hash_sha1_from_text( const char *psz_string, if( gcry_md_open( &hd, GCRY_MD_SHA1, 0 ) ) return NULL; - if( hash_from_string( psz_string, hd, p_sig->type == TEXT_SIGNATURE ) < 0 ) + if( p_sig->type == TEXT_SIGNATURE ) + while( *psz_string ) { - gcry_md_close( hd ); - return NULL; + size_t i_len = strcspn( psz_string, "\r\n" ); + if( !i_len ) + break; + + gcry_md_write( hd, psz_string, i_len ); + gcry_md_putc( hd, '\r' ); + gcry_md_putc( hd, '\n' ); + + psz_string += i_len; + while( *psz_string == '\r' || *psz_string == '\n' ) + psz_string++; } + else + gcry_md_write( hd, psz_string, strlen( psz_string ) ); return hash_finish( hd, p_sig ); } @@ -1028,3 +1014,5 @@ int download_signature( vlc_object_t *p_this, signature_packet_t *p_sig, return VLC_SUCCESS; } + +#endif /* UPDATE_CHECK */