Skip to content

Commit

Permalink
libavformat/r3d.c: Fix Use-of-uninitialized-value in filename.
Browse files Browse the repository at this point in the history
While reading the filename tag, it may return a EOF and we are still
copying the file with uninitialized value.

Signed-off-by: Michael Niedermayer <[email protected]>
  • Loading branch information
lotharkript authored and michaelni committed Aug 20, 2020
1 parent a606e3b commit 36f7b83
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libavformat/r3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 ret < 0 ? ret : AVERROR_EOF;
filename[sizeof(filename)-1] = 0;
av_dict_set(&st->metadata, "filename", filename, 0);

Expand Down

0 comments on commit 36f7b83

Please sign in to comment.