[FFmpeg-cvslog] lavf/rtpenc_jpeg: Error out for non-standard Huffman tables.

Carl Eugen Hoyos git at videolan.org
Thu Jul 9 20:15:19 CEST 2015


ffmpeg | branch: master | Carl Eugen Hoyos <cehoyos at ag.or.at> | Thu Jul  9 20:03:38 2015 +0200| [e786e96be70adb084f0dc672900302c577a347cf] | committer: Carl Eugen Hoyos

lavf/rtpenc_jpeg: Error out for non-standard Huffman tables.

Related to ticket #3823.

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

 libavformat/rtpenc_jpeg.c |   20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/libavformat/rtpenc_jpeg.c b/libavformat/rtpenc_jpeg.c
index e05e9b5..13d61a9 100644
--- a/libavformat/rtpenc_jpeg.c
+++ b/libavformat/rtpenc_jpeg.c
@@ -21,6 +21,7 @@
 
 #include "libavcodec/bytestream.h"
 #include "libavcodec/mjpeg.h"
+#include "libavcodec/jpegtables.h"
 #include "libavutil/intreadwrite.h"
 #include "rtpenc.h"
 
@@ -81,6 +82,25 @@ void ff_rtp_send_jpeg(AVFormatContext *s1, const uint8_t *buf, int size)
                        "Only 1x1 chroma blocks are supported. Aborted!\n");
                 return;
             }
+        } else if (buf[i + 1] == DHT) {
+            if (   AV_RB16(&buf[i + 2]) < 418
+                || i + 420 >= size
+                || buf[i +   4] != 0x00
+                || buf[i +  33] != 0x01
+                || buf[i +  62] != 0x10
+                || buf[i + 241] != 0x11
+                || memcmp(buf + i +   5, avpriv_mjpeg_bits_dc_luminance   + 1, 16)
+                || memcmp(buf + i +  21, avpriv_mjpeg_val_dc, 12)
+                || memcmp(buf + i +  34, avpriv_mjpeg_bits_dc_chrominance + 1, 16)
+                || memcmp(buf + i +  50, avpriv_mjpeg_val_dc, 12)
+                || memcmp(buf + i +  63, avpriv_mjpeg_bits_ac_luminance   + 1, 16)
+                || memcmp(buf + i +  79, avpriv_mjpeg_val_ac_luminance, 162)
+                || memcmp(buf + i + 242, avpriv_mjpeg_bits_ac_chrominance + 1, 16)
+                || memcmp(buf + i + 258, avpriv_mjpeg_val_ac_chrominance, 162)) {
+                av_log(s1, AV_LOG_ERROR,
+                       "RFC 2435 requires standard Huffman tables for jpeg\n");
+                return;
+            }
         } else if (buf[i + 1] == SOS) {
             /* SOS is last marker in the header */
             i += AV_RB16(&buf[i + 2]) + 2;



More information about the ffmpeg-cvslog mailing list