[FFmpeg-cvslog] mpjpeg: Cope with multipart lacking the initial CRLF

Luca Barbato git at videolan.org
Tue Oct 27 12:59:08 CET 2015


ffmpeg | branch: master | Luca Barbato <lu_zero at gentoo.org> | Thu Oct 22 05:07:05 2015 +0200| [18f9308e6a96bbeb034ee5213a6d41e0b6c2ae74] | committer: Luca Barbato

mpjpeg: Cope with multipart lacking the initial CRLF

Some server in the wild do not put the boundary at a newline
as rfc1347 7.2.1 states.
Cope with that by reading a line and if it is not empty reading
a second one.

Reported-By: bitingsock

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=18f9308e6a96bbeb034ee5213a6d41e0b6c2ae74
---

 libavformat/mpjpegdec.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/libavformat/mpjpegdec.c b/libavformat/mpjpegdec.c
index fda4c38..2888fb5 100644
--- a/libavformat/mpjpegdec.c
+++ b/libavformat/mpjpegdec.c
@@ -153,10 +153,20 @@ static int parse_multipart_header(AVFormatContext *s)
     int found_content_type = 0;
     int ret, size = -1;
 
+    // get the CRLF as empty string
     ret = get_line(s->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(s->pb, line, sizeof(line));
+        if (ret < 0)
+            return ret;
+    }
+
     if (strncmp(line, "--", 2))
         return AVERROR_INVALIDDATA;
 
@@ -208,9 +218,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;
 }
 



More information about the ffmpeg-cvslog mailing list