diff mbox series

[FFmpeg-devel] avformat/yuv4mpegdec: better error logging

Message ID 20200126152203.3549-1-ffmpeg@gyani.pro
State Accepted
Headers show
Series [FFmpeg-devel] avformat/yuv4mpegdec: better error logging
Related show

Checks

Context Check Description
andriy/ffmpeg-patchwork pending
andriy/ffmpeg-patchwork success Applied patch
andriy/ffmpeg-patchwork success Configure finished
andriy/ffmpeg-patchwork success Make finished
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Gyan Doshi Jan. 26, 2020, 3:22 p.m. UTC
---
 libavformat/yuv4mpegdec.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

Comments

Carl Eugen Hoyos Jan. 26, 2020, 3:28 p.m. UTC | #1
Am So., 26. Jan. 2020 um 16:22 Uhr schrieb Gyan Doshi <ffmpeg@gyani.pro>:
>
> ---
>  libavformat/yuv4mpegdec.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/libavformat/yuv4mpegdec.c b/libavformat/yuv4mpegdec.c
> index eceb945bb1..d7b472e6c7 100644
> --- a/libavformat/yuv4mpegdec.c
> +++ b/libavformat/yuv4mpegdec.c
> @@ -53,10 +53,14 @@ static int yuv4_read_header(AVFormatContext *s)
>              break;
>          }
>      }
> -    if (i == MAX_YUV4_HEADER)
> -        return -1;
> -    if (strncmp(header, Y4M_MAGIC, strlen(Y4M_MAGIC)))
> -        return -1;
> +    if (i == MAX_YUV4_HEADER) {
> +        av_log(s, AV_LOG_ERROR, "Header too large.\n");
> +        return AVERROR(EINVAL);
> +    }
> +    if (strncmp(header, Y4M_MAGIC, strlen(Y4M_MAGIC))) {
> +        av_log(s, AV_LOG_ERROR, "Invalid magic number for yuv4mpeg.\n");
> +        return AVERROR(EINVAL);

lgtm

Carl Eugen
Gyan Doshi Jan. 26, 2020, 4:21 p.m. UTC | #2
On 26-01-2020 08:58 pm, Carl Eugen Hoyos wrote:
> Am So., 26. Jan. 2020 um 16:22 Uhr schrieb Gyan Doshi <ffmpeg@gyani.pro>:
>> ---
>>   libavformat/yuv4mpegdec.c | 12 ++++++++----
>>   1 file changed, 8 insertions(+), 4 deletions(-)
>>
>> diff --git a/libavformat/yuv4mpegdec.c b/libavformat/yuv4mpegdec.c
>> index eceb945bb1..d7b472e6c7 100644
>> --- a/libavformat/yuv4mpegdec.c
>> +++ b/libavformat/yuv4mpegdec.c
>> @@ -53,10 +53,14 @@ static int yuv4_read_header(AVFormatContext *s)
>>               break;
>>           }
>>       }
>> -    if (i == MAX_YUV4_HEADER)
>> -        return -1;
>> -    if (strncmp(header, Y4M_MAGIC, strlen(Y4M_MAGIC)))
>> -        return -1;
>> +    if (i == MAX_YUV4_HEADER) {
>> +        av_log(s, AV_LOG_ERROR, "Header too large.\n");
>> +        return AVERROR(EINVAL);
>> +    }
>> +    if (strncmp(header, Y4M_MAGIC, strlen(Y4M_MAGIC))) {
>> +        av_log(s, AV_LOG_ERROR, "Invalid magic number for yuv4mpeg.\n");
>> +        return AVERROR(EINVAL);
> lgtm

Thanks. Pushed as 724e6b3d63786a910188a83a0d30c67c4fb359a9

Gyan
diff mbox series

Patch

diff --git a/libavformat/yuv4mpegdec.c b/libavformat/yuv4mpegdec.c
index eceb945bb1..d7b472e6c7 100644
--- a/libavformat/yuv4mpegdec.c
+++ b/libavformat/yuv4mpegdec.c
@@ -53,10 +53,14 @@  static int yuv4_read_header(AVFormatContext *s)
             break;
         }
     }
-    if (i == MAX_YUV4_HEADER)
-        return -1;
-    if (strncmp(header, Y4M_MAGIC, strlen(Y4M_MAGIC)))
-        return -1;
+    if (i == MAX_YUV4_HEADER) {
+        av_log(s, AV_LOG_ERROR, "Header too large.\n");
+        return AVERROR(EINVAL);
+    }
+    if (strncmp(header, Y4M_MAGIC, strlen(Y4M_MAGIC))) {
+        av_log(s, AV_LOG_ERROR, "Invalid magic number for yuv4mpeg.\n");
+        return AVERROR(EINVAL);
+    }
 
     header_end = &header[i + 1]; // Include space
     for (tokstart = &header[strlen(Y4M_MAGIC) + 1];