diff mbox

[FFmpeg-devel,04/11] avformat/apngdec: Return error when header incomplete

Message ID 20191210215955.11178-4-andreas.rheinhardt@gmail.com
State Superseded
Headers show

Commit Message

Andreas Rheinhardt Dec. 10, 2019, 9:59 p.m. UTC
When an incomplete header is encountered, apng_read_header would under
certain circumstances only return the return value of the last
successfull call. So override this by returning AVERROR_EOF manually.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
 libavformat/apngdec.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

James Almer Dec. 10, 2019, 10:16 p.m. UTC | #1
On 12/10/2019 6:59 PM, Andreas Rheinhardt wrote:
> When an incomplete header is encountered, apng_read_header would under
> certain circumstances only return the return value of the last
> successfull call. So override this by returning AVERROR_EOF manually.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
>  libavformat/apngdec.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavformat/apngdec.c b/libavformat/apngdec.c
> index 0f1d04a365..6c58fd9d04 100644
> --- a/libavformat/apngdec.c
> +++ b/libavformat/apngdec.c
> @@ -240,6 +240,8 @@ static int apng_read_header(AVFormatContext *s)
>          }
>      }
>  
> +    return AVERROR_EOF;

An incomplete header is invalid/truncated data, so this should be either
AVERROR_INVALIDDATA or AVERROR(EIO).

> +
>  fail:
>      return ret;
>  }
>
Nicolas George Dec. 12, 2019, 12:07 p.m. UTC | #2
James Almer (12019-12-10):
> An incomplete header is invalid/truncated data, so this should be either
> AVERROR_INVALIDDATA or AVERROR(EIO).

AVERROR_INVALIDDATA ok, but not AVERROR(EIO): there was no input our
output error, except if reported by the underlying layer.

We have been using AVERROR(EIO) as a default error for some time because
we did not have the proper codes, but now we have.

Regards,
diff mbox

Patch

diff --git a/libavformat/apngdec.c b/libavformat/apngdec.c
index 0f1d04a365..6c58fd9d04 100644
--- a/libavformat/apngdec.c
+++ b/libavformat/apngdec.c
@@ -240,6 +240,8 @@  static int apng_read_header(AVFormatContext *s)
         }
     }
 
+    return AVERROR_EOF;
+
 fail:
     return ret;
 }