[vlc-commits] update: fix hashing of text files with empty lines

Rafaël Carré git at videolan.org
Mon May 16 21:45:11 CEST 2011


vlc | branch: master | Rafaël Carré <rafael.carre at gmail.com> | Mon May 16 13:30:39 2011 -0400| [b3c26d999de3d0d56edf93e32ff448725010a1ff] | committer: Rafaël Carré

update: fix hashing of text files with empty lines

the current status file for 1.1.9 is one of these

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b3c26d999de3d0d56edf93e32ff448725010a1ff
---

 src/misc/update_crypto.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/misc/update_crypto.c b/src/misc/update_crypto.c
index f16cb0f..5bcea77 100644
--- a/src/misc/update_crypto.c
+++ b/src/misc/update_crypto.c
@@ -730,15 +730,18 @@ uint8_t *hash_sha1_from_text( const char *psz_string,
     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( i_len )
+        {
+            gcry_md_write( hd, psz_string, i_len );
+            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' )
+        if( *psz_string == '\r' )
+            psz_string++;
+        if( *psz_string == '\n' )
             psz_string++;
     }
     else



More information about the vlc-commits mailing list