changeset 32709:f1b29f413940

Correct translation of filenames and prevent out-of-bounds array access
author ib
date Tue, 18 Jan 2011 11:39:49 +0000
parents 29b63f338a9b
children 13b1606a71a4
files gui/mplayer/gui_common.c
diffstat 1 files changed, 5 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/gui/mplayer/gui_common.c	Tue Jan 18 11:30:46 2011 +0000
+++ b/gui/mplayer/gui_common.c	Tue Jan 18 11:39:49 2011 +0000
@@ -54,6 +54,7 @@
 {
  int i;
  char * p;
+ size_t len;
 
  switch ( guiIntfStruct.StreamType )
   {
@@ -67,8 +68,10 @@
               av_strlcpy(tmp, p + 1, tmplen);
             else
               av_strlcpy(tmp, guiIntfStruct.Filename, tmplen);
-            if ( tmp[strlen( tmp ) - 4] == '.' ) tmp[strlen( tmp ) - 4]=0;
-            if ( tmp[strlen( tmp ) - 5] == '.' ) tmp[strlen( tmp ) - 5]=0;
+            len=strlen( tmp );
+            if ( ( len > 3 )&&( tmp[len - 3] == '.' ) ) tmp[len - 3]=0;
+            else if ( ( len > 4 )&&( tmp[len - 4] == '.' ) ) tmp[len - 4]=0;
+            else if ( ( len > 5 )&&( tmp[len - 5] == '.' ) ) tmp[len - 5]=0;
            } else av_strlcpy( tmp,MSGTR_NoFileLoaded,tmplen );
           break;
 #ifdef CONFIG_DVDREAD