aboutsummaryrefslogtreecommitdiffstats
path: root/fftools/ffmpeg_demux.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-04-13 15:56:54 +0200
committerAnton Khirnov <anton@khirnov.net>2023-04-17 11:49:34 +0200
commit89c9a3ac3542c3684e511607d88b265bfa6aa64f (patch)
tree7969641e3755b37c9234eb37a9215b396fb0b11f /fftools/ffmpeg_demux.c
parent65e537b83379d2d6f87343f9bd59968b21d949a3 (diff)
downloadffmpeg-89c9a3ac3542c3684e511607d88b265bfa6aa64f.tar.gz
fftools/ffmpeg: avoid possible invalid reads with short -tag values
Fixes #10319 and #10309.
Diffstat (limited to 'fftools/ffmpeg_demux.c')
-rw-r--r--fftools/ffmpeg_demux.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index b9849d1669..d89e28b9f6 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -736,8 +736,12 @@ static void add_input_streams(const OptionsContext *o, Demuxer *d)
MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, ic, st);
if (codec_tag) {
uint32_t tag = strtol(codec_tag, &next, 0);
- if (*next)
- tag = AV_RL32(codec_tag);
+ if (*next) {
+ uint8_t buf[4] = { 0 };
+ memcpy(buf, codec_tag, FFMIN(sizeof(buf), strlen(codec_tag)));
+ tag = AV_RL32(buf);
+ }
+
st->codecpar->codec_tag = tag;
}