mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-04-19 09:02:26 +02:00
fftools/ffmpeg: avoid possible invalid reads with short -tag values
Fixes #10319 and #10309. Based on 89c9a3ac3542c3684e511607d88b265bfa6aa64f.
This commit is contained in:
parent
c36f69d7e3
commit
1e413487bf
@ -898,8 +898,11 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
|
|||||||
MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, ic, st);
|
MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, ic, st);
|
||||||
if (codec_tag) {
|
if (codec_tag) {
|
||||||
uint32_t tag = strtol(codec_tag, &next, 0);
|
uint32_t tag = strtol(codec_tag, &next, 0);
|
||||||
if (*next)
|
if (*next) {
|
||||||
tag = AV_RL32(codec_tag);
|
uint8_t buf[4] = { 0 };
|
||||||
|
memcpy(buf, codec_tag, FFMIN(sizeof(buf), strlen(codec_tag)));
|
||||||
|
tag = AV_RL32(buf);
|
||||||
|
}
|
||||||
st->codecpar->codec_tag = tag;
|
st->codecpar->codec_tag = tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1660,8 +1663,11 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
|
|||||||
MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, oc, st);
|
MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, oc, st);
|
||||||
if (codec_tag) {
|
if (codec_tag) {
|
||||||
uint32_t tag = strtol(codec_tag, &next, 0);
|
uint32_t tag = strtol(codec_tag, &next, 0);
|
||||||
if (*next)
|
if (*next) {
|
||||||
tag = AV_RL32(codec_tag);
|
uint8_t buf[4] = { 0 };
|
||||||
|
memcpy(buf, codec_tag, FFMIN(sizeof(buf), strlen(codec_tag)));
|
||||||
|
tag = AV_RL32(buf);
|
||||||
|
}
|
||||||
ost->st->codecpar->codec_tag =
|
ost->st->codecpar->codec_tag =
|
||||||
ost->enc_ctx->codec_tag = tag;
|
ost->enc_ctx->codec_tag = tag;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user