[08/18] jpeg2000dec: Add more checks when parsing headers

Message ID 1379358389-64839-8-git-send-email-martin@martin.st
State Superseded
Headers show

Commit Message

Martin Storsjö Sept. 16, 2013, 7:06 p.m.
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
---
 libavcodec/jpeg2000dec.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Luca Barbato Sept. 16, 2013, 9:37 p.m. | #1
On 16/09/13 21:06, Martin Storsjö wrote:
> Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> CC: libav-stable@libav.org
> ---
>  libavcodec/jpeg2000dec.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
> index 61befdf..b01abb2 100644
> --- a/libavcodec/jpeg2000dec.c
> +++ b/libavcodec/jpeg2000dec.c
> @@ -1280,8 +1280,8 @@ static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
>              Jpeg2000Tile *tile;
>              Jpeg2000TilePart *tp;
>  
> -            if (s->curtileno < 0) {
> -                av_log(s->avctx, AV_LOG_ERROR, "Missing SOT\n");
> +            if (s->curtileno < 0 || !s->tile) {
> +                av_log(s->avctx, AV_LOG_ERROR, "Missing SOT or SIZ\n");
>                  return AVERROR_INVALIDDATA;
>              }

If you feel motivated, make two message.

lu

Patch

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 61befdf..b01abb2 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -1280,8 +1280,8 @@  static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
             Jpeg2000Tile *tile;
             Jpeg2000TilePart *tp;
 
-            if (s->curtileno < 0) {
-                av_log(s->avctx, AV_LOG_ERROR, "Missing SOT\n");
+            if (s->curtileno < 0 || !s->tile) {
+                av_log(s->avctx, AV_LOG_ERROR, "Missing SOT or SIZ\n");
                 return AVERROR_INVALIDDATA;
             }