[PATCH] iff: do not decode unsupported pbms with ham decoder
This prevents the segfault reported by ticket #1054 --- libavcodec/iff.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/libavcodec/iff.c b/libavcodec/iff.c index 9b09604..30ce70d 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -635,12 +635,15 @@ static int decode_frame_byterun1(AVCodecContext *avctx, uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]]; buf += decode_byterun(row, avctx->width, buf, buf_end); } - } else { // IFF-PBM: HAM to PIX_FMT_BGR32 + } else if (s->ham) { // IFF-PBM: HAM to PIX_FMT_BGR32 for (y = 0; y < avctx->height ; y++) { uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]]; buf += decode_byterun(s->ham_buf, avctx->width, buf, buf_end); decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, s->planesize); } + } else { + av_log_ask_for_sample(avctx, "unsupported bpp\n"); + return AVERROR_INVALIDDATA; } *data_size = sizeof(AVFrame); -- 1.7.5.4 -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
On 3/11/12, Peter Ross <pross@xvid.org> wrote:
This prevents the segfault reported by ticket #1054
Does this fix real source of crash or just adds "workaround"?
--- libavcodec/iff.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/libavcodec/iff.c b/libavcodec/iff.c index 9b09604..30ce70d 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -635,12 +635,15 @@ static int decode_frame_byterun1(AVCodecContext *avctx, uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]]; buf += decode_byterun(row, avctx->width, buf, buf_end); } - } else { // IFF-PBM: HAM to PIX_FMT_BGR32 + } else if (s->ham) { // IFF-PBM: HAM to PIX_FMT_BGR32 for (y = 0; y < avctx->height ; y++) { uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]]; buf += decode_byterun(s->ham_buf, avctx->width, buf, buf_end); decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, s->planesize); } + } else { + av_log_ask_for_sample(avctx, "unsupported bpp\n");
OK, alternatively it could be treated as invalid.
On Sun, Mar 11, 2012 at 11:48:11PM +0000, Paul B Mahol wrote:
On 3/11/12, Peter Ross <pross@xvid.org> wrote:
This prevents the segfault reported by ticket #1054
Does this fix real source of crash or just adds "workaround"?
Yes, it fixes the source of the segfault. The 's->ham_buf' buffer is only allocated for HAM images, yet we were invoking the HAM decoder anyway for unsupported non-HAM images. Writing to the allocated buffer triggered the segfault. So this patch places a 'if (s->ham) {' guard around the decoder, and print out an appropriate warning for unsupported files.
--- libavcodec/iff.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/libavcodec/iff.c b/libavcodec/iff.c index 9b09604..30ce70d 100644 --- a/libavcodec/iff.c +++ b/libavcodec/iff.c @@ -635,12 +635,15 @@ static int decode_frame_byterun1(AVCodecContext *avctx, uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]]; buf += decode_byterun(row, avctx->width, buf, buf_end); } - } else { // IFF-PBM: HAM to PIX_FMT_BGR32 + } else if (s->ham) { // IFF-PBM: HAM to PIX_FMT_BGR32 for (y = 0; y < avctx->height ; y++) { uint8_t *row = &s->frame.data[0][y*s->frame.linesize[0]]; buf += decode_byterun(s->ham_buf, avctx->width, buf, buf_end); decode_ham_plane32((uint32_t *) row, s->ham_buf, s->ham_palbuf, s->planesize); } + } else { + av_log_ask_for_sample(avctx, "unsupported bpp\n");
OK, alternatively it could be treated as invalid. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel -- Peter (A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)
On 3/12/12, Peter Ross <pross@xvid.org> wrote:
On Sun, Mar 11, 2012 at 11:48:11PM +0000, Paul B Mahol wrote:
On 3/11/12, Peter Ross <pross@xvid.org> wrote:
This prevents the segfault reported by ticket #1054
Does this fix real source of crash or just adds "workaround"?
Yes, it fixes the source of the segfault.
The 's->ham_buf' buffer is only allocated for HAM images, yet we were invoking the HAM decoder anyway for unsupported non-HAM images. Writing to the allocated buffer triggered the segfault.
So this patch places a 'if (s->ham) {' guard around the decoder, and print out an appropriate warning for unsupported files.
OK, you will need to rebase patch...
participants (2)
-
Paul B Mahol -
Peter Ross