[MPlayer-dev-eng] [PATCH]printf format string used everywhere

Frédéric Marchal fmarchal at perso.be
Wed Oct 13 20:44:12 CEST 2010


On Saturday 09 October 2010 14:10:38 Reimar Döffinger wrote:
> On Fri, Oct 08, 2010 at 09:20:49PM +0200, Frédéric Marchal wrote:
> > On Thursday 07 October 2010 21:09:48 Reimar Döffinger wrote:
> > > On Wed, Sep 15, 2010 at 01:38:28PM +0200, Frédéric Marchal wrote:
> > > > Index: stream/librtsp/rtsp_rtp.c
> > > > -  snprintf (dest, len, parse1 + strlen (RTSP_SETUP_DESTINATION));
> > > > +  snprintf (dest, len, "%s", parse1 + strlen
> > > > (RTSP_SETUP_DESTINATION));
> > > 
> > > av_strlcpy ?
> > 
> > There are four other instances of snprintf("%s") with three of them that
> > are probable candidates for the same change. Should I try to replace
> > those too ?
> 
> Would make sense IMO.

Let's try this patch then. Excuse me for the poor quality of the previous patch. I hope
this one is better...

The change in gui/mplayer/gui_common.c breaks the symmetry with the other cases
that are using snprintf to format their numeric argument. You may want not to apply
it.

Frederic

---
Index: stream/librtsp/rtsp_rtp.c
===================================================================
--- stream/librtsp/rtsp_rtp.c	(revision 32483)
+++ stream/librtsp/rtsp_rtp.c	(working copy)
@@ -218,7 +218,7 @@
   len = strlen (parse1) - strlen (parse2)
     - strlen (RTSP_SETUP_DESTINATION) + 1;
   dest = (char *) malloc (len + 1);
-  snprintf (dest, len, parse1 + strlen (RTSP_SETUP_DESTINATION));
+  av_strlcpy (dest, parse1 + strlen (RTSP_SETUP_DESTINATION), len);
   free (line_copy);
 
   return dest;
Index: gui/mplayer/gtk/gtk_menu.c
===================================================================
--- gui/mplayer/gtk/gtk_menu.c	(revision 32483)
+++ gui/mplayer/gtk/gtk_menu.c	(working copy)
@@ -533,7 +533,7 @@
        AddMenuItem( window1, (const char*)empty1px_xpm, DVDSubtitleLanguageMenu,MSGTR_MENU_None,( 
(unsigned short)-1 << 16 ) + evSetDVDSubtitle );
        for ( i=0;i < guiIntfStruct.DVD.nr_of_subtitles;i++ )
         {
-	 snprintf( tmp,64,"%s",GetLanguage( guiIntfStruct.DVD.subtitles[i].language ) );
+	 av_strlcpy( tmp,GetLanguage( guiIntfStruct.DVD.subtitles[i].language ),sizeof(tmp) );
          AddMenuCheckItem( window1, (const char*)empty1px_xpm, DVDSubtitleLanguageMenu,tmp,
 			   dvdsub_id == guiIntfStruct.DVD.subtitles[i].id,
 			   ( guiIntfStruct.DVD.subtitles[i].id << 16 ) + evSetDVDSubtitle );
Index: gui/mplayer/gui_common.c
===================================================================
--- gui/mplayer/gui_common.c	(revision 32483)
+++ gui/mplayer/gui_common.c	(working copy)
@@ -156,7 +156,7 @@
 		 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
        case 'y': snprintf( tmp,sizeof( tmp ),"%d",guiIntfStruct.MovieHeight );
 		 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
-       case 'C': snprintf( tmp,sizeof( tmp ),"%s", guiIntfStruct.sh_video? ((sh_video_t *)guiIntfStruct.sh_video)->codec-
>name : "");
+       case 'C': av_strlcpy( tmp, guiIntfStruct.sh_video? ((sh_video_t *)guiIntfStruct.sh_video)->codec->name : 
"",sizeof( tmp ));
                  av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
        case 's': if ( guiIntfStruct.Playing == 0 ) av_strlcat( trbuf,"s",sizeof( trbuf ) ); break;
        case 'l': if ( guiIntfStruct.Playing == 1 ) av_strlcat( trbuf,"p",sizeof( trbuf ) ); break;


More information about the MPlayer-dev-eng mailing list