[02/10] shorten: Break out of loop looking for fmt chunk if none is found

Message ID 1378932481-98398-2-git-send-email-martin@martin.st
State Committed
Commit b26742cc308552f242ee2bf93b07a3ff509f4edc
Headers show

Commit Message

Martin Storsjö Sept. 11, 2013, 8:47 p.m.
Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
CC: libav-stable@libav.org
---
 libavcodec/shorten.c |    4 ++++
 1 file changed, 4 insertions(+)

Comments

Kostya Shishkov Sept. 12, 2013, 4:46 a.m. | #1
On Wed, Sep 11, 2013 at 11:47:53PM +0300, Martin Storsjö wrote:
> Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
> CC: libav-stable@libav.org
> ---
>  libavcodec/shorten.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
> index 130bde6..c394c52 100644
> --- a/libavcodec/shorten.c
> +++ b/libavcodec/shorten.c
> @@ -221,6 +221,10 @@ static int decode_wave_header(AVCodecContext *avctx, const uint8_t *header,
>      while (bytestream2_get_le32(&gb) != MKTAG('f', 'm', 't', ' ')) {
>          len = bytestream2_get_le32(&gb);
>          bytestream2_skip(&gb, len);
> +        if (bytestream2_get_bytes_left(&gb) < 16) {
> +            av_log(avctx, AV_LOG_ERROR, "no fmt chunk found\n");
> +            return AVERROR_INVALIDDATA;
> +        }
>      }
>      len = bytestream2_get_le32(&gb);
>  
> -- 

looks OK

Patch

diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
index 130bde6..c394c52 100644
--- a/libavcodec/shorten.c
+++ b/libavcodec/shorten.c
@@ -221,6 +221,10 @@  static int decode_wave_header(AVCodecContext *avctx, const uint8_t *header,
     while (bytestream2_get_le32(&gb) != MKTAG('f', 'm', 't', ' ')) {
         len = bytestream2_get_le32(&gb);
         bytestream2_skip(&gb, len);
+        if (bytestream2_get_bytes_left(&gb) < 16) {
+            av_log(avctx, AV_LOG_ERROR, "no fmt chunk found\n");
+            return AVERROR_INVALIDDATA;
+        }
     }
     len = bytestream2_get_le32(&gb);