X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fmpjpegdec.c;h=2749a48acecf8fd4df70037f345d8602c746d3e5;hb=c89e075d5a66e095c4c21d6bb7ecd80bb1137f73;hp=c76ea560e731d64b36a64f73927f97cdc0244d92;hpb=d307c44bafc67ffa5c05c49148d994e64266d3b9;p=ffmpeg diff --git a/libavformat/mpjpegdec.c b/libavformat/mpjpegdec.c index c76ea560e73..2749a48acec 100644 --- a/libavformat/mpjpegdec.c +++ b/libavformat/mpjpegdec.c @@ -98,7 +98,7 @@ static int mpjpeg_read_probe(AVProbeData *p) pb = avio_alloc_context(p->buf, p->buf_size, 0, NULL, NULL, NULL, NULL); if (!pb) - return AVERROR(ENOMEM); + return 0; ret = (parse_multipart_header(pb, NULL)>0)?AVPROBE_SCORE_MAX:0; @@ -153,10 +153,20 @@ static int parse_multipart_header(AVIOContext *pb, void *log_ctx) int found_content_type = 0; int ret, size = -1; + // get the CRLF as empty string ret = get_line(pb, line, sizeof(line)); if (ret < 0) return ret; + /* some implementation do not provide the required + * initial CRLF (see rfc1341 7.2.1) + */ + if (!line[0]) { + ret = get_line(pb, line, sizeof(line)); + if (ret < 0) + return ret; + } + if (strncmp(line, "--", 2)) return AVERROR_INVALIDDATA; @@ -216,9 +226,6 @@ static int mpjpeg_read_packet(AVFormatContext *s, AVPacket *pkt) if (ret < 0) return ret; - // trailing empty line - avio_skip(s->pb, 2); - return 0; }