diff mbox series

[FFmpeg-devel,1/2] avcodec/flashsv: Check inflate() for failure

Message ID 20220523003529.21527-1-michael@niedermayer.cc
State Accepted
Commit 8f6432cd77aa832727edf8f225c0f9016eab4085
Headers show
Series [FFmpeg-devel,1/2] avcodec/flashsv: Check inflate() for failure | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer May 23, 2022, 12:35 a.m. UTC
Fixes: CID1047223

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/flashsv.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Michael Niedermayer July 7, 2022, 6:32 p.m. UTC | #1
On Mon, May 23, 2022 at 02:35:28AM +0200, Michael Niedermayer wrote:
> Fixes: CID1047223
> 
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/flashsv.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)

will apply patchset

[...]
diff mbox series

Patch

diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c
index 0982161d49..d8943d9cf8 100644
--- a/libavcodec/flashsv.c
+++ b/libavcodec/flashsv.c
@@ -149,7 +149,9 @@  static int flashsv2_prime(FlashSVContext *s, const uint8_t *src, int size)
     zstream->avail_in  = size;
     zstream->next_out  = data;
     zstream->avail_out = s->block_size * 3;
-    inflate(zstream, Z_SYNC_FLUSH);
+    zret = inflate(zstream, Z_SYNC_FLUSH);
+    if (zret != Z_OK && zret != Z_STREAM_END)
+        return AVERROR_UNKNOWN;
     remaining = s->block_size * 3 - zstream->avail_out;
 
     if ((zret = inflateReset(zstream)) != Z_OK) {
@@ -165,7 +167,9 @@  static int flashsv2_prime(FlashSVContext *s, const uint8_t *src, int size)
      * out of the output from above. See section 3.2.4 of RFC 1951. */
     zstream->next_in  = zlib_header;
     zstream->avail_in = sizeof(zlib_header);
-    inflate(zstream, Z_SYNC_FLUSH);
+    zret = inflate(zstream, Z_SYNC_FLUSH);
+    if (zret != Z_OK)
+        return AVERROR_UNKNOWN;
     while (remaining > 0) {
         unsigned block_size = FFMIN(UINT16_MAX, remaining);
         uint8_t header[5];