[vlc-commits] update: avoid division by zero

Rémi Denis-Courmont git at videolan.org
Wed Oct 21 19:05:24 CEST 2015


vlc/vlc-2.2 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Aug 31 20:11:52 2015 +0300| [eda813bdc0d1c20980ec978e92057d01227a0cbd] | committer: Jean-Baptiste Kempf

update: avoid division by zero

If the downloaded file is empty or of unknown size.

(cherry picked from commit 145b05739d2dc9607ead4ef8244ba2172d97b389)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 src/misc/update.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/src/misc/update.c b/src/misc/update.c
index e1257b7..9650313 100644
--- a/src/misc/update.c
+++ b/src/misc/update.c
@@ -472,7 +472,7 @@ bool update_NeedUpgrade( update_t *p_update )
  * \param l_size the size in bytes
  * \return the size as a string
  */
-static char *size_str( long int l_size )
+static char *size_str( uint64_t l_size )
 {
     char *psz_tmp = NULL;
     int i_retval = 0;
@@ -527,8 +527,8 @@ static void* update_DownloadReal( void *obj )
 {
     update_download_thread_t *p_udt = (update_download_thread_t *)obj;
     dialog_progress_bar_t *p_progress = NULL;
-    long int l_size;
-    long int l_downloaded = 0;
+    uint64_t l_size;
+    uint64_t l_downloaded = 0;
     float f_progress;
     char *psz_status;
     char *psz_downloaded = NULL;
@@ -557,7 +557,8 @@ static void* update_DownloadReal( void *obj )
     }
 
     /* Get the stream size */
-    l_size = stream_Size( p_stream );
+    if( stream_GetSize( p_stream, &l_size ) || l_size == 0 )
+        goto end;
 
     /* Get the file name and open it*/
     psz_tmpdestfile = strrchr( p_update->release.psz_url, '/' );



More information about the vlc-commits mailing list