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] fftools/ffmpeg_mux_init: Return error upon error
@ 2024-06-10 13:24 Andreas Rheinhardt
  2024-06-11  5:35 ` Anton Khirnov
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Rheinhardt @ 2024-06-10 13:24 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Andreas Rheinhardt

Currently it may return an uninitialized value.
Introduced in 840f2bc18eddd72fa886aec30efc82991b920c45.
Fixes Coverity issue #1603565.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 fftools/ffmpeg_mux_init.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index b1cb6cf7bd..1953655135 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -3022,10 +3022,13 @@ static int parse_forced_key_frames(void *log, KeyframeForceCtx *kf,
             unsigned int    nb_ch = mux->fc->nb_chapters;
             int j;
 
-            if (nb_ch > INT_MAX - size ||
-                !(pts = av_realloc_f(pts, size += nb_ch - 1,
-                                     sizeof(*pts))))
+            if (nb_ch > INT_MAX - size) {
+                ret = AVERROR(ERANGE);
                 goto fail;
+            }
+            pts = av_realloc_f(pts, size += nb_ch - 1, sizeof(*pts));
+            if (!pts)
+                return AVERROR(ENOMEM);
 
             if (p[8]) {
                 ret = av_parse_time(&t, p + 8, 1);
-- 
2.40.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] fftools/ffmpeg_mux_init: Return error upon error
  2024-06-10 13:24 [FFmpeg-devel] [PATCH] fftools/ffmpeg_mux_init: Return error upon error Andreas Rheinhardt
@ 2024-06-11  5:35 ` Anton Khirnov
  2024-06-11  6:38   ` Andreas Rheinhardt
  0 siblings, 1 reply; 4+ messages in thread
From: Anton Khirnov @ 2024-06-11  5:35 UTC (permalink / raw)
  To: FFmpeg development discussions and patches; +Cc: Andreas Rheinhardt

Quoting Andreas Rheinhardt (2024-06-10 15:24:49)
> Currently it may return an uninitialized value.
> Introduced in 840f2bc18eddd72fa886aec30efc82991b920c45.
> Fixes Coverity issue #1603565.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
>  fftools/ffmpeg_mux_init.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
> index b1cb6cf7bd..1953655135 100644
> --- a/fftools/ffmpeg_mux_init.c
> +++ b/fftools/ffmpeg_mux_init.c
> @@ -3022,10 +3022,13 @@ static int parse_forced_key_frames(void *log, KeyframeForceCtx *kf,
>              unsigned int    nb_ch = mux->fc->nb_chapters;
>              int j;
>  
> -            if (nb_ch > INT_MAX - size ||
> -                !(pts = av_realloc_f(pts, size += nb_ch - 1,
> -                                     sizeof(*pts))))
> +            if (nb_ch > INT_MAX - size) {
> +                ret = AVERROR(ERANGE);
>                  goto fail;
> +            }
> +            pts = av_realloc_f(pts, size += nb_ch - 1, sizeof(*pts));
> +            if (!pts)
> +                return AVERROR(ENOMEM);

Looks good.

Would look even better with the size increment outside of the
av_realloc_f() call.

-- 
Anton Khirnov
_______________________________________________
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] fftools/ffmpeg_mux_init: Return error upon error
  2024-06-11  5:35 ` Anton Khirnov
@ 2024-06-11  6:38   ` Andreas Rheinhardt
  2024-06-11  6:40     ` Andreas Rheinhardt
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Rheinhardt @ 2024-06-11  6:38 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Anton Khirnov:
> Quoting Andreas Rheinhardt (2024-06-10 15:24:49)
>> Currently it may return an uninitialized value.
>> Introduced in 840f2bc18eddd72fa886aec30efc82991b920c45.
>> Fixes Coverity issue #1603565.
>>
>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>> ---
>>  fftools/ffmpeg_mux_init.c | 9 ++++++---
>>  1 file changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
>> index b1cb6cf7bd..1953655135 100644
>> --- a/fftools/ffmpeg_mux_init.c
>> +++ b/fftools/ffmpeg_mux_init.c
>> @@ -3022,10 +3022,13 @@ static int parse_forced_key_frames(void *log, KeyframeForceCtx *kf,
>>              unsigned int    nb_ch = mux->fc->nb_chapters;
>>              int j;
>>  
>> -            if (nb_ch > INT_MAX - size ||
>> -                !(pts = av_realloc_f(pts, size += nb_ch - 1,
>> -                                     sizeof(*pts))))
>> +            if (nb_ch > INT_MAX - size) {
>> +                ret = AVERROR(ERANGE);
>>                  goto fail;
>> +            }
>> +            pts = av_realloc_f(pts, size += nb_ch - 1, sizeof(*pts));
>> +            if (!pts)
>> +                return AVERROR(ENOMEM);
> 
> Looks good.
> 
> Would look even better with the size increment outside of the
> av_realloc_f() call.
> 

Apply with that change.

- Andreas

_______________________________________________
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] fftools/ffmpeg_mux_init: Return error upon error
  2024-06-11  6:38   ` Andreas Rheinhardt
@ 2024-06-11  6:40     ` Andreas Rheinhardt
  0 siblings, 0 replies; 4+ messages in thread
From: Andreas Rheinhardt @ 2024-06-11  6:40 UTC (permalink / raw)
  To: ffmpeg-devel

Andreas Rheinhardt:
> Anton Khirnov:
>> Quoting Andreas Rheinhardt (2024-06-10 15:24:49)
>>> Currently it may return an uninitialized value.
>>> Introduced in 840f2bc18eddd72fa886aec30efc82991b920c45.
>>> Fixes Coverity issue #1603565.
>>>
>>> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
>>> ---
>>>  fftools/ffmpeg_mux_init.c | 9 ++++++---
>>>  1 file changed, 6 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
>>> index b1cb6cf7bd..1953655135 100644
>>> --- a/fftools/ffmpeg_mux_init.c
>>> +++ b/fftools/ffmpeg_mux_init.c
>>> @@ -3022,10 +3022,13 @@ static int parse_forced_key_frames(void *log, KeyframeForceCtx *kf,
>>>              unsigned int    nb_ch = mux->fc->nb_chapters;
>>>              int j;
>>>  
>>> -            if (nb_ch > INT_MAX - size ||
>>> -                !(pts = av_realloc_f(pts, size += nb_ch - 1,
>>> -                                     sizeof(*pts))))
>>> +            if (nb_ch > INT_MAX - size) {
>>> +                ret = AVERROR(ERANGE);
>>>                  goto fail;
>>> +            }
>>> +            pts = av_realloc_f(pts, size += nb_ch - 1, sizeof(*pts));
>>> +            if (!pts)
>>> +                return AVERROR(ENOMEM);
>>
>> Looks good.
>>
>> Would look even better with the size increment outside of the
>> av_realloc_f() call.
>>
> 
> Apply with that change.

s/Apply/Applied/

> 
> - Andreas
> 
> _______________________________________________
> 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

end of thread, other threads:[~2024-06-11  6:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-10 13:24 [FFmpeg-devel] [PATCH] fftools/ffmpeg_mux_init: Return error upon error Andreas Rheinhardt
2024-06-11  5:35 ` Anton Khirnov
2024-06-11  6:38   ` Andreas Rheinhardt
2024-06-11  6:40     ` Andreas Rheinhardt

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