diff mbox series

[FFmpeg-devel] libavformat/r3d.c: Fix Use-of-uninitialized-value in filename.

Message ID 20200819225102.215654-1-tfoucu@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel] libavformat/r3d.c: Fix Use-of-uninitialized-value in filename.
Related show

Checks

Context Check Description
andriy/default pending
andriy/make success Make finished
andriy/make_fate success Make fate finished

Commit Message

Thierry Foucu Aug. 19, 2020, 10:51 p.m. UTC
While reading the filename tag, it mays return a EOF and we are still
copying the file with uninitialized value.
---
 libavformat/r3d.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Michael Niedermayer Aug. 20, 2020, 11:23 a.m. UTC | #1
On Wed, Aug 19, 2020 at 03:51:02PM -0700, Thierry Foucu wrote:
> While reading the filename tag, it mays return a EOF and we are still
> copying the file with uninitialized value.
> ---
>  libavformat/r3d.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/libavformat/r3d.c b/libavformat/r3d.c
> index 7aa0c5a2c3..d013b8c30e 100644
> --- a/libavformat/r3d.c
> +++ b/libavformat/r3d.c
> @@ -56,6 +56,7 @@ static int r3d_read_red1(AVFormatContext *s)
>      R3DContext *r3d = s->priv_data;
>      char filename[258];
>      int tmp;
> +    int ret;
>      int av_unused tmp2;
>      AVRational framerate;
>  
> @@ -97,7 +98,9 @@ static int r3d_read_red1(AVFormatContext *s)
>      r3d->audio_channels = avio_r8(s->pb); // audio channels
>      av_log(s, AV_LOG_TRACE, "audio channels %d\n", tmp);
>  
> -    avio_read(s->pb, filename, 257);
> +    ret = avio_read(s->pb, filename, 257);
> +    if (ret < 257)
> +        return AVERROR_EOF;

will apply with a modification so the error code is not lost if theres
is one

thx

[...]
diff mbox series

Patch

diff --git a/libavformat/r3d.c b/libavformat/r3d.c
index 7aa0c5a2c3..d013b8c30e 100644
--- a/libavformat/r3d.c
+++ b/libavformat/r3d.c
@@ -56,6 +56,7 @@  static int r3d_read_red1(AVFormatContext *s)
     R3DContext *r3d = s->priv_data;
     char filename[258];
     int tmp;
+    int ret;
     int av_unused tmp2;
     AVRational framerate;
 
@@ -97,7 +98,9 @@  static int r3d_read_red1(AVFormatContext *s)
     r3d->audio_channels = avio_r8(s->pb); // audio channels
     av_log(s, AV_LOG_TRACE, "audio channels %d\n", tmp);
 
-    avio_read(s->pb, filename, 257);
+    ret = avio_read(s->pb, filename, 257);
+    if (ret < 257)
+        return AVERROR_EOF;
     filename[sizeof(filename)-1] = 0;
     av_dict_set(&st->metadata, "filename", filename, 0);