[FFmpeg-cvslog] avcodec/iff: Check ham vs bpp

2019-07-08 Thread Michael Niedermayer
ffmpeg | branch: release/4.1 | Michael Niedermayer  | 
Sat Jun 22 19:21:50 2019 +0200| [d534cb834564f440c6368b5c6597c67e1f97635d] | 
committer: Michael Niedermayer

avcodec/iff: Check ham vs bpp

This checks the ham value much stricter and avoids hitting cases which cannot 
be reached
with data from the libavformat demuxer.

Fixes: out of array access
Fixes: 
15320/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5080476840099840
Fixes: 
15423/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5630765833912320

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
(cherry picked from commit f76d7352e05526fde7c607b9a9db536a5760af29)
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index 4099d118e4..c6e2359b00 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -280,6 +280,16 @@ static int extract_header(AVCodecContext *const avctx,
 for (i = 0; i < 16; i++)
 s->tvdc[i] = bytestream_get_be16();
 
+if (s->ham) {
+if (s->bpp > 8) {
+av_log(avctx, AV_LOG_ERROR, "Invalid number of hold bits for 
HAM: %u\n", s->ham);
+return AVERROR_INVALIDDATA;
+} if (s->ham != (s->bpp > 6 ? 6 : 4)) {
+av_log(avctx, AV_LOG_ERROR, "Invalid number of hold bits for 
HAM: %u, BPP: %u\n", s->ham, s->bpp);
+return AVERROR_INVALIDDATA;
+}
+}
+
 if (s->masking == MASK_HAS_MASK) {
 if (s->bpp >= 8 && !s->ham) {
 avctx->pix_fmt = AV_PIX_FMT_RGB32;
@@ -307,9 +317,6 @@ static int extract_header(AVCodecContext *const avctx,
 if (!s->bpp || s->bpp > 32) {
 av_log(avctx, AV_LOG_ERROR, "Invalid number of bitplanes: %u\n", 
s->bpp);
 return AVERROR_INVALIDDATA;
-} else if (s->ham >= 8) {
-av_log(avctx, AV_LOG_ERROR, "Invalid number of hold bits for HAM: 
%u\n", s->ham);
-return AVERROR_INVALIDDATA;
 }
 
 av_freep(>ham_buf);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-cvslog] avcodec/iff: Check ham vs bpp

2019-07-08 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Sat 
Jun 22 19:21:50 2019 +0200| [f76d7352e05526fde7c607b9a9db536a5760af29] | 
committer: Michael Niedermayer

avcodec/iff: Check ham vs bpp

This checks the ham value much stricter and avoids hitting cases which cannot 
be reached
with data from the libavformat demuxer.

Fixes: out of array access
Fixes: 
15320/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5080476840099840
Fixes: 
15423/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_IFF_ILBM_fuzzer-5630765833912320

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 

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

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

diff --git a/libavcodec/iff.c b/libavcodec/iff.c
index 4099d118e4..c6e2359b00 100644
--- a/libavcodec/iff.c
+++ b/libavcodec/iff.c
@@ -280,6 +280,16 @@ static int extract_header(AVCodecContext *const avctx,
 for (i = 0; i < 16; i++)
 s->tvdc[i] = bytestream_get_be16();
 
+if (s->ham) {
+if (s->bpp > 8) {
+av_log(avctx, AV_LOG_ERROR, "Invalid number of hold bits for 
HAM: %u\n", s->ham);
+return AVERROR_INVALIDDATA;
+} if (s->ham != (s->bpp > 6 ? 6 : 4)) {
+av_log(avctx, AV_LOG_ERROR, "Invalid number of hold bits for 
HAM: %u, BPP: %u\n", s->ham, s->bpp);
+return AVERROR_INVALIDDATA;
+}
+}
+
 if (s->masking == MASK_HAS_MASK) {
 if (s->bpp >= 8 && !s->ham) {
 avctx->pix_fmt = AV_PIX_FMT_RGB32;
@@ -307,9 +317,6 @@ static int extract_header(AVCodecContext *const avctx,
 if (!s->bpp || s->bpp > 32) {
 av_log(avctx, AV_LOG_ERROR, "Invalid number of bitplanes: %u\n", 
s->bpp);
 return AVERROR_INVALIDDATA;
-} else if (s->ham >= 8) {
-av_log(avctx, AV_LOG_ERROR, "Invalid number of hold bits for HAM: 
%u\n", s->ham);
-return AVERROR_INVALIDDATA;
 }
 
 av_freep(>ham_buf);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".