Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avformat: Add check for ff_get_extradata
@ 2022-02-22  7:49 Jiasheng Jiang
  2022-02-22  8:10 ` Paul B Mahol
  0 siblings, 1 reply; 4+ messages in thread
From: Jiasheng Jiang @ 2022-02-22  7:49 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Jiasheng Jiang

As the potential failure of the memory allocation, the ff_get_extradata()
could return error if fails.
Therefore, it should be better to deal with the return value of the
ff_get_extradata() and return error if fails.

Fixes: 2d720069a9 ("avformat: add aix demuxer")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
 libavformat/aixdec.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavformat/aixdec.c b/libavformat/aixdec.c
index 59c3d60da3..89f73b6913 100644
--- a/libavformat/aixdec.c
+++ b/libavformat/aixdec.c
@@ -40,7 +40,7 @@ static int aix_read_header(AVFormatContext *s)
     unsigned segment_list_offset = 0x20;
     unsigned segment_list_entry_size = 0x10;
     unsigned size;
-    int i;
+    int i, ret;
 
     avio_skip(s->pb, 4);
     first_offset = avio_rb32(s->pb) + 8;
@@ -77,7 +77,9 @@ static int aix_read_header(AVFormatContext *s)
         if (size <= 8)
             return AVERROR_INVALIDDATA;
         avio_skip(s->pb, 8);
-        ff_get_extradata(s, s->streams[i]->codecpar, s->pb, size - 8);
+        ret = ff_get_extradata(s, s->streams[i]->codecpar, s->pb, size - 8);
+        if (ret < 0)
+            return ret;
     }
 
     return 0;
-- 
2.25.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avformat: Add check for ff_get_extradata
  2022-02-22  7:49 [FFmpeg-devel] [PATCH] avformat: Add check for ff_get_extradata Jiasheng Jiang
@ 2022-02-22  8:10 ` Paul B Mahol
  0 siblings, 0 replies; 4+ messages in thread
From: Paul B Mahol @ 2022-02-22  8:10 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Jiasheng Jiang

On Tue, Feb 22, 2022 at 8:50 AM Jiasheng Jiang <jiasheng@iscas.ac.cn> wrote:

> As the potential failure of the memory allocation, the ff_get_extradata()
> could return error if fails.
> Therefore, it should be better to deal with the return value of the
> ff_get_extradata() and return error if fails.
>


Not really necessary. Does not fix anything.


>
> Fixes: 2d720069a9 ("avformat: add aix demuxer")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
>  libavformat/aixdec.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/aixdec.c b/libavformat/aixdec.c
> index 59c3d60da3..89f73b6913 100644
> --- a/libavformat/aixdec.c
> +++ b/libavformat/aixdec.c
> @@ -40,7 +40,7 @@ static int aix_read_header(AVFormatContext *s)
>      unsigned segment_list_offset = 0x20;
>      unsigned segment_list_entry_size = 0x10;
>      unsigned size;
> -    int i;
> +    int i, ret;
>
>      avio_skip(s->pb, 4);
>      first_offset = avio_rb32(s->pb) + 8;
> @@ -77,7 +77,9 @@ static int aix_read_header(AVFormatContext *s)
>          if (size <= 8)
>              return AVERROR_INVALIDDATA;
>          avio_skip(s->pb, 8);
> -        ff_get_extradata(s, s->streams[i]->codecpar, s->pb, size - 8);
> +        ret = ff_get_extradata(s, s->streams[i]->codecpar, s->pb, size -
> 8);
> +        if (ret < 0)
> +            return ret;
>      }
>
>      return 0;
> --
> 2.25.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avformat: Add check for ff_get_extradata
  2022-02-22  9:14 Jiasheng Jiang
@ 2022-02-22  9:30 ` Paul B Mahol
  0 siblings, 0 replies; 4+ messages in thread
From: Paul B Mahol @ 2022-02-22  9:30 UTC (permalink / raw)
  To: Jiasheng Jiang; +Cc: FFmpeg development discussions and patches

On Tue, Feb 22, 2022 at 10:14 AM Jiasheng Jiang <jiasheng@iscas.ac.cn>
wrote:

> On Tue, Feb 22, 2022 at 04:10:51PM +0800, Paul B Mahol wrote:
>
> >> As the potential failure of the memory allocation, the
> ff_get_extradata()
> >> could return error if fails.
> >> Therefore, it should be better to deal with the return value of the
> >> ff_get_extradata() and return error if fails.
> >>
> >
> >
> > Not really necessary. Does not fix anything.
>
> It is true that the 'extradata' could be NULL and have not used.
> But I have checked many other callers of the ff_get_extradata(),
> such as avi_read_header() in `libavformat/avidec.c`.
> They all have checked the return value to guarantee the 'extradata'
> to be non-NULL.
> That means in the future, if the 'aix->extradata' is used, the programmer
> may not notice that 'aix->extradata' is especial and needs to be checked
> before use.
> Therefore, I think it is necessary to add the check to guarantee the
> consisitency of the code.
>

Nope, that does not make sense, it should always be checked.


>
> Thanks,
> Jiang
>
>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [FFmpeg-devel] [PATCH] avformat: Add check for ff_get_extradata
@ 2022-02-22  9:14 Jiasheng Jiang
  2022-02-22  9:30 ` Paul B Mahol
  0 siblings, 1 reply; 4+ messages in thread
From: Jiasheng Jiang @ 2022-02-22  9:14 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Jiasheng Jiang, onemda

On Tue, Feb 22, 2022 at 04:10:51PM +0800, Paul B Mahol wrote:

>> As the potential failure of the memory allocation, the ff_get_extradata()
>> could return error if fails.
>> Therefore, it should be better to deal with the return value of the
>> ff_get_extradata() and return error if fails.
>>
> 
> 
> Not really necessary. Does not fix anything.

It is true that the 'extradata' could be NULL and have not used.
But I have checked many other callers of the ff_get_extradata(),
such as avi_read_header() in `libavformat/avidec.c`.
They all have checked the return value to guarantee the 'extradata'
to be non-NULL.
That means in the future, if the 'aix->extradata' is used, the programmer
may not notice that 'aix->extradata' is especial and needs to be checked
before use.
Therefore, I think it is necessary to add the check to guarantee the
consisitency of the code.

Thanks,
Jiang

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-22  9:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-22  7:49 [FFmpeg-devel] [PATCH] avformat: Add check for ff_get_extradata Jiasheng Jiang
2022-02-22  8:10 ` Paul B Mahol
2022-02-22  9:14 Jiasheng Jiang
2022-02-22  9:30 ` Paul B Mahol

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git