[FFmpeg-devel] [PATCH 3/3] avformat/microdvd: skip BOM properly

Clément Bœsch u at pkh.me
Tue Feb 18 21:38:11 CET 2014


On Mon, Feb 17, 2014 at 09:49:36PM +0100, wm4 wrote:
> The BOM is already skipped in the probe function, but not the header
> read function. This could cause the header to be misparsed (not reading
> the FPS line).
> ---
>  libavformat/microdvddec.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/microdvddec.c b/libavformat/microdvddec.c
> index 51f7f48..0a301b6 100644
> --- a/libavformat/microdvddec.c
> +++ b/libavformat/microdvddec.c
> @@ -77,17 +77,23 @@ static int microdvd_read_header(AVFormatContext *s)
>      MicroDVDContext *microdvd = s->priv_data;
>      AVStream *st = avformat_new_stream(s, NULL);
>      int i = 0;
> -    char line[MAX_LINESIZE];
> +    char line_buf[MAX_LINESIZE];
>      int has_real_fps = 0;
>  
>      if (!st)
>          return AVERROR(ENOMEM);
>  
>      while (!url_feof(s->pb)) {
> -        char *p = line;
> +        char *p;
>          AVPacket *sub;
>          int64_t pos = avio_tell(s->pb);
> -        int len = ff_get_line(s->pb, line, sizeof(line));
> +        int len = ff_get_line(s->pb, line_buf, sizeof(line_buf));

> +        const char *bom = "\xEF\xBB\xBF";

static and move it just above the function.

> +        char *line = line_buf;
> +
> +        if (!strncmp(line, bom, 3))
> +            line += 3;
> +        p = line;
>  

otherwise looks OK

Note: this problem is probably present in some other sub demuxer.

-- 
Clément B.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140218/a6018fb8/attachment.asc>


More information about the ffmpeg-devel mailing list