]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/adx.c
ff_emulated_edge_mc: fix handling of w/h being 0
[ffmpeg] / libavcodec / adx.c
index aa90fd89c3dfba9f4c1cfd8f84f54ee4d62d5900..7da696d0a8e9140236c58a41ba9ed88b652660ca 100644 (file)
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/mathematics.h"
 #include "adx.h"
@@ -46,6 +47,11 @@ int avpriv_adx_decode_header(AVCodecContext *avctx, const uint8_t *buf,
         return AVERROR_INVALIDDATA;
     offset = AV_RB16(buf + 2) + 4;
 
+    if (offset < 6) {
+        av_log(avctx, AV_LOG_ERROR, "offset is prior data\n");
+        return AVERROR_INVALIDDATA;
+    }
+
     /* if copyright string is within the provided data, validate it */
     if (bufsize >= offset && memcmp(buf + offset - 6, "(c)CRI", 6))
         return AVERROR_INVALIDDATA;
@@ -58,7 +64,7 @@ int avpriv_adx_decode_header(AVCodecContext *avctx, const uint8_t *buf,
 
     /* channels */
     avctx->channels = buf[7];
-    if (avctx->channels > 2)
+    if (avctx->channels <= 0 || avctx->channels > 2)
         return AVERROR_INVALIDDATA;
 
     /* sample rate */