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

Reimar Döffinger Reimar.Doeffinger at gmx.de
Sat Oct 9 14:10:38 CEST 2010


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.

> Index: libmpcodecs/vd_ffmpeg.c
> ===================================================================
> --- libmpcodecs/vd_ffmpeg.c	(revision 32451)
> +++ libmpcodecs/vd_ffmpeg.c	(working copy)
> @@ -227,7 +227,7 @@
>  
>      print_prefix= strchr(fmt, '\n') != NULL;
>      vsnprintf(buf, sizeof(buf), fmt, vl);
> -    mp_msg(type, mp_level, buf);
> +    mp_msg(type, mp_level, "%s", buf);
>  }

I have a different solution, using a va_list mp_msg version.

> Index: vidix/mtrr.c
> ===================================================================
> --- vidix/mtrr.c	(revision 32451)
> +++ vidix/mtrr.c	(working copy)
> @@ -54,13 +54,11 @@
>      mtrr_fd = fopen("/proc/mtrr","wt");
>      if(mtrr_fd)
>      {
> -	char sout[256];
>  	unsigned wr_len;
> -	sprintf(sout,"base=0x%08X size=0x%08X type=%s\n",base,size,stype);
> -	wr_len = fprintf(mtrr_fd,sout);
> -	/*printf("MTRR: %s\n",sout);*/
> +	wr_len = fprintf(mtrr_fd,"base=0x%08X size=0x%08X type=%s\n",base,size,stype);
> +	/*printf("MTRR: base=0x%08X size=0x%08X type=%s\n",base,size,stype);*/
>  	fclose(mtrr_fd);
> -	return wr_len == strlen(sout) ? 0 : EPERM;
> +	return wr_len < 0 ? 0 : EPERM;

wr_len cannot be < 0 due to someone stupidly having used the wrong
type. You also swapped the return values in addition.
Anyway, done differently.


More information about the MPlayer-dev-eng mailing list