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

Frédéric Marchal fmarchal at perso.be
Thu Oct 7 17:03:59 CEST 2010


Hello,

I haven't got any news from this patch. Was it overlooked ?

Frederic

On Wednesday 15 September 2010 13:38:28 Frédéric Marchal wrote:
> Hello,
> 
> I'm submitting this trivial patch to force the use of a format string in
> every printf-like function. It has two advantages:
> 
> 1) In the unlikely case where the string to print contains a sequence that
> looks like a valid format specifier, the function won't fail while reading
> the missing arguments.
> 
> 2) It is possible to compile with -Wformat -Werror=format-security in the
> CFLAGS and increase the confidence that every printf-like function is
> parsing the right arguments.
> 
> Frederic
> 
> ---
> Index: libmpcodecs/vd_ffmpeg.c
> ===================================================================
> --- libmpcodecs/vd_ffmpeg.c     (révision 32250)
> +++ libmpcodecs/vd_ffmpeg.c     (copie de travail)
> @@ -227,7 +227,7 @@ static void mp_msp_av_log_callback(void *ptr, int
> 
>      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);
>  }
> 
>  static void set_format_params(struct AVCodecContext *avctx, enum
> PixelFormat fmt){ Index: stream/librtsp/rtsp_rtp.c
> ===================================================================
> --- stream/librtsp/rtsp_rtp.c   (révision 32250)
> +++ stream/librtsp/rtsp_rtp.c   (copie de travail)
> @@ -218,7 +218,7 @@ parse_destination (const char *line)
>    len = strlen (parse1) - strlen (parse2)
>      - strlen (RTSP_SETUP_DESTINATION) + 1;
>    dest = (char *) malloc (len + 1);
> -  snprintf (dest, len, parse1 + strlen (RTSP_SETUP_DESTINATION));
> +  snprintf (dest, len, "%s", parse1 + strlen (RTSP_SETUP_DESTINATION));
>    free (line_copy);
> 
>    return dest;
> Index: vidix/mtrr.c
> ===================================================================
> --- vidix/mtrr.c        (révision 32250)
> +++ vidix/mtrr.c        (copie de travail)
> @@ -57,7 +57,7 @@ int   mtrr_set_type(unsigned base,unsigned size,int
>         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);
> +       wr_len = fprintf(mtrr_fd,"%s",sout);
>         /*printf("MTRR: %s\n",sout);*/
>         fclose(mtrr_fd);
>         return wr_len == strlen(sout) ? 0 : EPERM;
> _______________________________________________
> MPlayer-dev-eng mailing list
> MPlayer-dev-eng at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/mplayer-dev-eng


More information about the MPlayer-dev-eng mailing list