* [FFmpeg-devel] [PATCH 02/15] avformat/jacosubdec: Factorize code in get_shift() a bit
2023-09-30 22:30 [FFmpeg-devel] [PATCH 01/15] avformat/concatdec: Check in/outpoint for overflow Michael Niedermayer
@ 2023-09-30 22:30 ` Michael Niedermayer
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 03/15] avformat/jacosubdec: avoid signed integer overflows in get_shift() Michael Niedermayer
` (14 subsequent siblings)
15 siblings, 0 replies; 22+ messages in thread
From: Michael Niedermayer @ 2023-09-30 22:30 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavformat/jacosubdec.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/libavformat/jacosubdec.c b/libavformat/jacosubdec.c
index 61b1316dc9b..42c201f93af 100644
--- a/libavformat/jacosubdec.c
+++ b/libavformat/jacosubdec.c
@@ -143,16 +143,12 @@ static int get_shift(int timeres, const char *buf)
ret = 0;
switch (n) {
- case 4:
- ret = sign * (((int64_t)a*3600 + (int64_t)b*60 + c) * timeres + d);
- break;
- case 3:
- ret = sign * (( (int64_t)a*60 + b) * timeres + c);
- break;
- case 2:
- ret = sign * (( (int64_t)a) * timeres + b);
- break;
+ case 1: a = 0;
+ case 2: c = b; b = a; a = 0;
+ case 3: d = c; c = b; b = a; a = 0;
}
+
+ ret = sign * (((int64_t)a*3600 + (int64_t)b*60 + c) * timeres + d);
if ((int)ret != ret)
ret = 0;
--
2.17.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] 22+ messages in thread
* [FFmpeg-devel] [PATCH 03/15] avformat/jacosubdec: avoid signed integer overflows in get_shift()
2023-09-30 22:30 [FFmpeg-devel] [PATCH 01/15] avformat/concatdec: Check in/outpoint for overflow Michael Niedermayer
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 02/15] avformat/jacosubdec: Factorize code in get_shift() a bit Michael Niedermayer
@ 2023-09-30 22:30 ` Michael Niedermayer
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 04/15] avformat/jacosubdec: Check timeres Michael Niedermayer
` (13 subsequent siblings)
15 siblings, 0 replies; 22+ messages in thread
From: Michael Niedermayer @ 2023-09-30 22:30 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Fixes: signed integer overflow: 22014562800 * 934633746 cannot be represented in type 'long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_JACOSUB_fuzzer-5189603246866432
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavformat/jacosubdec.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/libavformat/jacosubdec.c b/libavformat/jacosubdec.c
index 42c201f93af..41216081ee0 100644
--- a/libavformat/jacosubdec.c
+++ b/libavformat/jacosubdec.c
@@ -124,7 +124,7 @@ shift_and_ret:
return buf + len;
}
-static int get_shift(int timeres, const char *buf)
+static int get_shift(unsigned timeres, const char *buf)
{
int sign = 1;
int a = 0, b = 0, c = 0, d = 0;
@@ -148,7 +148,11 @@ static int get_shift(int timeres, const char *buf)
case 3: d = c; c = b; b = a; a = 0;
}
- ret = sign * (((int64_t)a*3600 + (int64_t)b*60 + c) * timeres + d);
+ ret = (int64_t)a*3600 + (int64_t)b*60 + c;
+ if (FFABS(ret) > (INT64_MAX - FFABS(d)) / timeres)
+ return 0;
+ ret = sign * (ret * timeres + d);
+
if ((int)ret != ret)
ret = 0;
--
2.17.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] 22+ messages in thread
* [FFmpeg-devel] [PATCH 04/15] avformat/jacosubdec: Check timeres
2023-09-30 22:30 [FFmpeg-devel] [PATCH 01/15] avformat/concatdec: Check in/outpoint for overflow Michael Niedermayer
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 02/15] avformat/jacosubdec: Factorize code in get_shift() a bit Michael Niedermayer
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 03/15] avformat/jacosubdec: avoid signed integer overflows in get_shift() Michael Niedermayer
@ 2023-09-30 22:30 ` Michael Niedermayer
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 05/15] avformat/mov: compute absolute dts difference without overflow in mov_find_next_sample() Michael Niedermayer
` (12 subsequent siblings)
15 siblings, 0 replies; 22+ messages in thread
From: Michael Niedermayer @ 2023-09-30 22:30 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavformat/jacosubdec.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/libavformat/jacosubdec.c b/libavformat/jacosubdec.c
index 41216081ee0..c6e5b4aa6dc 100644
--- a/libavformat/jacosubdec.c
+++ b/libavformat/jacosubdec.c
@@ -227,14 +227,17 @@ static int jacosub_read_header(AVFormatContext *s)
}
av_bprintf(&header, "#S %s", p);
break;
- case 'T': // ...but must be placed after TIMERES
- jacosub->timeres = strtol(p, NULL, 10);
- if (!jacosub->timeres)
+ case 'T': { // ...but must be placed after TIMERES
+ int64_t timeres = strtol(p, NULL, 10);
+ if (timeres <= 0 || timeres > UINT32_MAX) {
jacosub->timeres = 30;
- else
+ } else {
+ jacosub->timeres = timeres;
av_bprintf(&header, "#T %s", p);
+ }
break;
}
+ }
}
/* general/essential directives in the extradata */
--
2.17.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] 22+ messages in thread
* [FFmpeg-devel] [PATCH 05/15] avformat/mov: compute absolute dts difference without overflow in mov_find_next_sample()
2023-09-30 22:30 [FFmpeg-devel] [PATCH 01/15] avformat/concatdec: Check in/outpoint for overflow Michael Niedermayer
` (2 preceding siblings ...)
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 04/15] avformat/jacosubdec: Check timeres Michael Niedermayer
@ 2023-09-30 22:30 ` Michael Niedermayer
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 06/15] avformat/rpl: Check for number_of_chunks overflow Michael Niedermayer
` (11 subsequent siblings)
15 siblings, 0 replies; 22+ messages in thread
From: Michael Niedermayer @ 2023-09-30 22:30 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Fixes: signed integer overflow: -9223372036854775808 - 9222726413022000000 cannot be represented in type 'long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-5959420033761280
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavformat/mov.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 294c864fbd6..369c9b2ffd9 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -8795,12 +8795,13 @@ static AVIndexEntry *mov_find_next_sample(AVFormatContext *s, AVStream **st)
if (msc->pb && msc->current_sample < avsti->nb_index_entries) {
AVIndexEntry *current_sample = &avsti->index_entries[msc->current_sample];
int64_t dts = av_rescale(current_sample->timestamp, AV_TIME_BASE, msc->time_scale);
+ uint64_t dtsdiff = best_dts > dts ? best_dts - (uint64_t)dts : ((uint64_t)dts - best_dts);
av_log(s, AV_LOG_TRACE, "stream %d, sample %d, dts %"PRId64"\n", i, msc->current_sample, dts);
if (!sample || (no_interleave && current_sample->pos < sample->pos) ||
((s->pb->seekable & AVIO_SEEKABLE_NORMAL) &&
((msc->pb != s->pb && dts < best_dts) || (msc->pb == s->pb && dts != AV_NOPTS_VALUE &&
- ((FFABS(best_dts - dts) <= AV_TIME_BASE && current_sample->pos < sample->pos) ||
- (FFABS(best_dts - dts) > AV_TIME_BASE && dts < best_dts)))))) {
+ ((dtsdiff <= AV_TIME_BASE && current_sample->pos < sample->pos) ||
+ (dtsdiff > AV_TIME_BASE && dts < best_dts)))))) {
sample = current_sample;
best_dts = dts;
*st = avst;
--
2.17.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] 22+ messages in thread
* [FFmpeg-devel] [PATCH 06/15] avformat/rpl: Check for number_of_chunks overflow
2023-09-30 22:30 [FFmpeg-devel] [PATCH 01/15] avformat/concatdec: Check in/outpoint for overflow Michael Niedermayer
` (3 preceding siblings ...)
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 05/15] avformat/mov: compute absolute dts difference without overflow in mov_find_next_sample() Michael Niedermayer
@ 2023-09-30 22:30 ` Michael Niedermayer
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 07/15] avformat/sbgdec: Check for period overflow Michael Niedermayer
` (10 subsequent siblings)
15 siblings, 0 replies; 22+ messages in thread
From: Michael Niedermayer @ 2023-09-30 22:30 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int32_t' (aka 'int')
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_RPL_fuzzer-6086131095830528
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavformat/rpl.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/libavformat/rpl.c b/libavformat/rpl.c
index 3ef6fda3862..eae0da891bc 100644
--- a/libavformat/rpl.c
+++ b/libavformat/rpl.c
@@ -268,6 +268,9 @@ static int rpl_read_header(AVFormatContext *s)
"Video stream will be broken!\n", av_fourcc2str(vst->codecpar->codec_tag));
number_of_chunks = read_line_and_int(pb, &error); // number of chunks in the file
+ if (number_of_chunks == INT_MAX)
+ return AVERROR_INVALIDDATA;
+
// The number in the header is actually the index of the last chunk.
number_of_chunks++;
--
2.17.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] 22+ messages in thread
* [FFmpeg-devel] [PATCH 07/15] avformat/sbgdec: Check for period overflow
2023-09-30 22:30 [FFmpeg-devel] [PATCH 01/15] avformat/concatdec: Check in/outpoint for overflow Michael Niedermayer
` (4 preceding siblings ...)
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 06/15] avformat/rpl: Check for number_of_chunks overflow Michael Niedermayer
@ 2023-09-30 22:30 ` Michael Niedermayer
2023-10-03 11:06 ` Nicolas George
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 08/15] avformat/sbgdec: Check for negative duration or un-representable end pts Michael Niedermayer
` (9 subsequent siblings)
15 siblings, 1 reply; 22+ messages in thread
From: Michael Niedermayer @ 2023-09-30 22:30 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Fixes: signed integer overflow: 4481246996173000000 - -4778576820000000000 cannot be represented in type 'long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-5063670588899328
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavformat/sbgdec.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libavformat/sbgdec.c b/libavformat/sbgdec.c
index c1995759a8f..73b5be9007d 100644
--- a/libavformat/sbgdec.c
+++ b/libavformat/sbgdec.c
@@ -1273,7 +1273,10 @@ static int generate_intervals(void *log, struct sbg_script *s, int sample_rate,
/* SBaGen handles the time before and after the extremal events,
and the corresponding transitions, as if the sequence were cyclic
with a 24-hours period. */
- period = s->events[s->nb_events - 1].ts - s->events[0].ts;
+ period = s->events[s->nb_events - 1].ts - (uint64_t)s->events[0].ts;
+ if (period < 0)
+ return AVERROR_INVALIDDATA;
+
period = (period + (DAY_TS - 1)) / DAY_TS * DAY_TS;
period = FFMAX(period, DAY_TS);
--
2.17.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] 22+ messages in thread
* Re: [FFmpeg-devel] [PATCH 07/15] avformat/sbgdec: Check for period overflow
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 07/15] avformat/sbgdec: Check for period overflow Michael Niedermayer
@ 2023-10-03 11:06 ` Nicolas George
2023-10-03 14:12 ` Michael Niedermayer
0 siblings, 1 reply; 22+ messages in thread
From: Nicolas George @ 2023-10-03 11:06 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Michael Niedermayer (12023-10-01):
> Fixes: signed integer overflow: 4481246996173000000 - -4778576820000000000 cannot be represented in type 'long'
> Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-5063670588899328
>
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
> libavformat/sbgdec.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
No objections.
Regards,
--
Nicolas George
_______________________________________________
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] 22+ messages in thread
* Re: [FFmpeg-devel] [PATCH 07/15] avformat/sbgdec: Check for period overflow
2023-10-03 11:06 ` Nicolas George
@ 2023-10-03 14:12 ` Michael Niedermayer
0 siblings, 0 replies; 22+ messages in thread
From: Michael Niedermayer @ 2023-10-03 14:12 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 974 bytes --]
On Tue, Oct 03, 2023 at 01:06:43PM +0200, Nicolas George wrote:
> Michael Niedermayer (12023-10-01):
> > Fixes: signed integer overflow: 4481246996173000000 - -4778576820000000000 cannot be represented in type 'long'
> > Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-5063670588899328
> >
> > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> > libavformat/sbgdec.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
>
> No objections.
will apply
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Dictatorship: All citizens are under surveillance, all their steps and
actions recorded, for the politicians to enforce control.
Democracy: All politicians are under surveillance, all their steps and
actions recorded, for the citizens to enforce control.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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] 22+ messages in thread
* [FFmpeg-devel] [PATCH 08/15] avformat/sbgdec: Check for negative duration or un-representable end pts
2023-09-30 22:30 [FFmpeg-devel] [PATCH 01/15] avformat/concatdec: Check in/outpoint for overflow Michael Niedermayer
` (5 preceding siblings ...)
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 07/15] avformat/sbgdec: Check for period overflow Michael Niedermayer
@ 2023-09-30 22:30 ` Michael Niedermayer
2023-10-03 14:40 ` Nicolas George
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 09/15] avformat/tta: Better totalframes check Michael Niedermayer
` (8 subsequent siblings)
15 siblings, 1 reply; 22+ messages in thread
From: Michael Niedermayer @ 2023-09-30 22:30 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Fixes: signed integer overflow: 9230955872951340 - -9223372036854775808 cannot be represented in type 'long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_SBG_fuzzer-6330481893572608
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavformat/sbgdec.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/libavformat/sbgdec.c b/libavformat/sbgdec.c
index 73b5be9007d..b2662ea4188 100644
--- a/libavformat/sbgdec.c
+++ b/libavformat/sbgdec.c
@@ -1447,6 +1447,13 @@ static av_cold int sbg_read_header(AVFormatContext *avf)
st->duration = script.end_ts == AV_NOPTS_VALUE ? AV_NOPTS_VALUE :
av_rescale(script.end_ts - script.start_ts,
sbg->sample_rate, AV_TIME_BASE);
+
+ if (st->duration != AV_NOPTS_VALUE && (
+ st->duration < 0 || st->start_time > INT64_MAX - st->duration)) {
+ r = AVERROR_INVALIDDATA;
+ goto fail;
+ }
+
sti->cur_dts = st->start_time;
r = encode_intervals(&script, st->codecpar, &inter);
if (r < 0)
--
2.17.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] 22+ messages in thread
* [FFmpeg-devel] [PATCH 09/15] avformat/tta: Better totalframes check
2023-09-30 22:30 [FFmpeg-devel] [PATCH 01/15] avformat/concatdec: Check in/outpoint for overflow Michael Niedermayer
` (6 preceding siblings ...)
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 08/15] avformat/sbgdec: Check for negative duration or un-representable end pts Michael Niedermayer
@ 2023-09-30 22:30 ` Michael Niedermayer
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 10/15] avformat/wavdec: Check left avio_tell for overflow Michael Niedermayer
` (7 subsequent siblings)
15 siblings, 0 replies; 22+ messages in thread
From: Michael Niedermayer @ 2023-09-30 22:30 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Fixes: signed integer overflow: 4 * 740491135 cannot be represented in type 'int'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_TTA_fuzzer-6298893367508992
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavformat/tta.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavformat/tta.c b/libavformat/tta.c
index 21830459401..54776540142 100644
--- a/libavformat/tta.c
+++ b/libavformat/tta.c
@@ -91,7 +91,7 @@ static int tta_read_header(AVFormatContext *s)
c->totalframes = nb_samples / c->frame_size + (c->last_frame_size < c->frame_size);
c->currentframe = 0;
- if(c->totalframes >= UINT_MAX/sizeof(uint32_t) || c->totalframes <= 0){
+ if(c->totalframes >= (INT_MAX - 4)/sizeof(uint32_t) || c->totalframes <= 0){
av_log(s, AV_LOG_ERROR, "totalframes %d invalid\n", c->totalframes);
return AVERROR_INVALIDDATA;
}
--
2.17.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] 22+ messages in thread
* [FFmpeg-devel] [PATCH 10/15] avformat/wavdec: Check left avio_tell for overflow
2023-09-30 22:30 [FFmpeg-devel] [PATCH 01/15] avformat/concatdec: Check in/outpoint for overflow Michael Niedermayer
` (7 preceding siblings ...)
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 09/15] avformat/tta: Better totalframes check Michael Niedermayer
@ 2023-09-30 22:30 ` Michael Niedermayer
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 11/15] avformat/matroskadec: Check prebuffered_ns " Michael Niedermayer
` (6 subsequent siblings)
15 siblings, 0 replies; 22+ messages in thread
From: Michael Niedermayer @ 2023-09-30 22:30 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Fixes: signed integer overflow: 155 + 9223372036854775655 cannot be represented in type 'long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_W64_fuzzer-5364032278495232
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavformat/wavdec.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/libavformat/wavdec.c b/libavformat/wavdec.c
index 97e69ab2ee4..b145e980414 100644
--- a/libavformat/wavdec.c
+++ b/libavformat/wavdec.c
@@ -767,6 +767,8 @@ smv_out:
goto smv_retry;
return AVERROR_EOF;
}
+ if (INT64_MAX - left < avio_tell(s->pb))
+ return AVERROR_INVALIDDATA;
wav->data_end = avio_tell(s->pb) + left;
}
--
2.17.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] 22+ messages in thread
* [FFmpeg-devel] [PATCH 11/15] avformat/matroskadec: Check prebuffered_ns for overflow
2023-09-30 22:30 [FFmpeg-devel] [PATCH 01/15] avformat/concatdec: Check in/outpoint for overflow Michael Niedermayer
` (8 preceding siblings ...)
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 10/15] avformat/wavdec: Check left avio_tell for overflow Michael Niedermayer
@ 2023-09-30 22:30 ` Michael Niedermayer
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 12/15] avformat/westwood_vqa: Do not leave vqfl_chunk_size invalid Michael Niedermayer
` (5 subsequent siblings)
15 siblings, 0 replies; 22+ messages in thread
From: Michael Niedermayer @ 2023-09-30 22:30 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Fixes: signed integer overflow: 9223372036630775808 + 1000000000 cannot be represented in type 'long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_WEBM_DASH_MANIFEST_fuzzer-5406131992526848
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavformat/matroskadec.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 941c0bcdc9f..ae8823ae58e 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -4537,13 +4537,17 @@ static int64_t webm_dash_manifest_compute_bandwidth(AVFormatContext *s, int64_t
int64_t prebuffer_ns = 1000000000;
int64_t time_ns = sti->index_entries[i].timestamp * matroska->time_scale;
double nano_seconds_per_second = 1000000000.0;
- int64_t prebuffered_ns = time_ns + prebuffer_ns;
+ int64_t prebuffered_ns;
double prebuffer_bytes = 0.0;
int64_t temp_prebuffer_ns = prebuffer_ns;
int64_t pre_bytes, pre_ns;
double pre_sec, prebuffer, bits_per_second;
CueDesc desc_beg = get_cue_desc(s, time_ns, cues_start);
+ if (time_ns > INT64_MAX - prebuffer_ns)
+ return -1;
+ prebuffered_ns = time_ns + prebuffer_ns;
+
// Start with the first Cue.
CueDesc desc_end = desc_beg;
--
2.17.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] 22+ messages in thread
* [FFmpeg-devel] [PATCH 12/15] avformat/westwood_vqa: Do not leave vqfl_chunk_size invalid
2023-09-30 22:30 [FFmpeg-devel] [PATCH 01/15] avformat/concatdec: Check in/outpoint for overflow Michael Niedermayer
` (9 preceding siblings ...)
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 11/15] avformat/matroskadec: Check prebuffered_ns " Michael Niedermayer
@ 2023-09-30 22:30 ` Michael Niedermayer
2023-09-30 22:48 ` Michael Niedermayer
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 13/15] avformat/xwma: sanity check bits_per_coded_sample Michael Niedermayer
` (4 subsequent siblings)
15 siblings, 1 reply; 22+ messages in thread
From: Michael Niedermayer @ 2023-09-30 22:30 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_WSVQA_fuzzer-4613908817903616
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavformat/westwood_vqa.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libavformat/westwood_vqa.c b/libavformat/westwood_vqa.c
index e3d2e2668c4..18948d14ccc 100644
--- a/libavformat/westwood_vqa.c
+++ b/libavformat/westwood_vqa.c
@@ -194,8 +194,10 @@ static int wsvqa_read_packet(AVFormatContext *s,
* includes a whole frame as expected. */
wsvqa->vqfl_chunk_pos = avio_tell(pb);
wsvqa->vqfl_chunk_size = (int)(chunk_size);
- if (wsvqa->vqfl_chunk_size < 0 || wsvqa->vqfl_chunk_size > 3 * (1 << 20))
+ if (wsvqa->vqfl_chunk_size < 0 || wsvqa->vqfl_chunk_size > 3 * (1 << 20)) {
+ wsvqa->vqfl_chunk_size = 0;
return AVERROR_INVALIDDATA;
+ }
/* We need a big seekback buffer because there can be SNxx, VIEW and ZBUF
* chunks (<512 KiB total) in the stream before we read VQFR (<256 KiB) and
* seek back here. */
--
2.17.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] 22+ messages in thread
* Re: [FFmpeg-devel] [PATCH 12/15] avformat/westwood_vqa: Do not leave vqfl_chunk_size invalid
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 12/15] avformat/westwood_vqa: Do not leave vqfl_chunk_size invalid Michael Niedermayer
@ 2023-09-30 22:48 ` Michael Niedermayer
0 siblings, 0 replies; 22+ messages in thread
From: Michael Niedermayer @ 2023-09-30 22:48 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 892 bytes --]
On Sun, Oct 01, 2023 at 12:30:43AM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 2147483647 + 1 cannot be represented in type 'int'
> Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_WSVQA_fuzzer-4613908817903616
>
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
> libavformat/westwood_vqa.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
patch withdrawn, i had written and submitted an alternative patch a year ago
and then forgot to apply it it seems
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Into a blind darkness they enter who follow after the Ignorance,
they as if into a greater darkness enter who devote themselves
to the Knowledge alone. -- Isha Upanishad
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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] 22+ messages in thread
* [FFmpeg-devel] [PATCH 13/15] avformat/xwma: sanity check bits_per_coded_sample
2023-09-30 22:30 [FFmpeg-devel] [PATCH 01/15] avformat/concatdec: Check in/outpoint for overflow Michael Niedermayer
` (10 preceding siblings ...)
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 12/15] avformat/westwood_vqa: Do not leave vqfl_chunk_size invalid Michael Niedermayer
@ 2023-09-30 22:30 ` Michael Niedermayer
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 14/15] avformat/asfdec_f: Saturate presentation time in marker Michael Niedermayer
` (3 subsequent siblings)
15 siblings, 0 replies; 22+ messages in thread
From: Michael Niedermayer @ 2023-09-30 22:30 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Fixes: signed integer overflow: 65312 * 524296 cannot be represented in type 'int'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_XWMA_fuzzer-6595971445555200
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavformat/xwma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavformat/xwma.c b/libavformat/xwma.c
index 12689f37fd7..b830f9ed75f 100644
--- a/libavformat/xwma.c
+++ b/libavformat/xwma.c
@@ -151,7 +151,7 @@ static int xwma_read_header(AVFormatContext *s)
st->codecpar->ch_layout.nb_channels);
return AVERROR_INVALIDDATA;
}
- if (!st->codecpar->bits_per_coded_sample) {
+ if (!st->codecpar->bits_per_coded_sample || st->codecpar->bits_per_coded_sample > 64) {
av_log(s, AV_LOG_WARNING, "Invalid bits_per_coded_sample: %d\n",
st->codecpar->bits_per_coded_sample);
return AVERROR_INVALIDDATA;
--
2.17.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] 22+ messages in thread
* [FFmpeg-devel] [PATCH 14/15] avformat/asfdec_f: Saturate presentation time in marker
2023-09-30 22:30 [FFmpeg-devel] [PATCH 01/15] avformat/concatdec: Check in/outpoint for overflow Michael Niedermayer
` (11 preceding siblings ...)
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 13/15] avformat/xwma: sanity check bits_per_coded_sample Michael Niedermayer
@ 2023-09-30 22:30 ` Michael Niedermayer
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 15/15] avcodec/h264_parser: saturate dts a bit Michael Niedermayer
` (2 subsequent siblings)
15 siblings, 0 replies; 22+ messages in thread
From: Michael Niedermayer @ 2023-09-30 22:30 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Fixes: signed integer overflow: -9223372036315799520 - 3873890816 cannot be represented in type 'long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5009302746431488
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavformat/asfdec_f.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavformat/asfdec_f.c b/libavformat/asfdec_f.c
index 54059564670..a579c3e894b 100644
--- a/libavformat/asfdec_f.c
+++ b/libavformat/asfdec_f.c
@@ -674,7 +674,7 @@ static int asf_read_marker(AVFormatContext *s)
avio_rl64(pb); // offset, 8 bytes
pres_time = avio_rl64(pb); // presentation time
- pres_time -= asf->hdr.preroll * 10000;
+ pres_time = av_sat_sub64(pres_time, asf->hdr.preroll * 10000);
avio_rl16(pb); // entry length
avio_rl32(pb); // send time
avio_rl32(pb); // flags
--
2.17.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] 22+ messages in thread
* [FFmpeg-devel] [PATCH 15/15] avcodec/h264_parser: saturate dts a bit
2023-09-30 22:30 [FFmpeg-devel] [PATCH 01/15] avformat/concatdec: Check in/outpoint for overflow Michael Niedermayer
` (12 preceding siblings ...)
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 14/15] avformat/asfdec_f: Saturate presentation time in marker Michael Niedermayer
@ 2023-09-30 22:30 ` Michael Niedermayer
2023-10-02 12:03 ` [FFmpeg-devel] [PATCH 01/15] avformat/concatdec: Check in/outpoint for overflow Nicolas George
2023-10-08 19:35 ` Michael Niedermayer
15 siblings, 0 replies; 22+ messages in thread
From: Michael Niedermayer @ 2023-09-30 22:30 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Fixes: signed integer overflow: 0 - -9223372036854775808 cannot be represented in type 'long'
Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_IO_DEMUXER_fuzzer-6112289464123392
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
libavcodec/h264_parser.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c
index 43abc45f9cd..6ab8f659cb6 100644
--- a/libavcodec/h264_parser.c
+++ b/libavcodec/h264_parser.c
@@ -646,10 +646,10 @@ static int h264_parse(AVCodecParserContext *s,
int64_t num = time_base.num * (int64_t)avctx->pkt_timebase.den;
if (s->dts != AV_NOPTS_VALUE) {
// got DTS from the stream, update reference timestamp
- p->reference_dts = s->dts - av_rescale(s->dts_ref_dts_delta, num, den);
+ p->reference_dts = av_sat_sub64(s->dts, av_rescale(s->dts_ref_dts_delta, num, den));
} else if (p->reference_dts != AV_NOPTS_VALUE) {
// compute DTS based on reference timestamp
- s->dts = p->reference_dts + av_rescale(s->dts_ref_dts_delta, num, den);
+ s->dts = av_sat_add64(p->reference_dts, av_rescale(s->dts_ref_dts_delta, num, den));
}
if (p->reference_dts != AV_NOPTS_VALUE && s->pts == AV_NOPTS_VALUE)
--
2.17.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] 22+ messages in thread
* Re: [FFmpeg-devel] [PATCH 01/15] avformat/concatdec: Check in/outpoint for overflow
2023-09-30 22:30 [FFmpeg-devel] [PATCH 01/15] avformat/concatdec: Check in/outpoint for overflow Michael Niedermayer
` (13 preceding siblings ...)
2023-09-30 22:30 ` [FFmpeg-devel] [PATCH 15/15] avcodec/h264_parser: saturate dts a bit Michael Niedermayer
@ 2023-10-02 12:03 ` Nicolas George
2023-10-03 14:11 ` Michael Niedermayer
2023-10-08 19:35 ` Michael Niedermayer
15 siblings, 1 reply; 22+ messages in thread
From: Nicolas George @ 2023-10-02 12:03 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Michael Niedermayer (12023-10-01):
> Fixes: signed integer overflow: 91542414454000000 - -9154241494546000000 cannot be represented in type 'long'
> Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-4739147999084544
>
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
> libavformat/concatdec.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
No objection.
Regards,
--
Nicolas George
_______________________________________________
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] 22+ messages in thread
* Re: [FFmpeg-devel] [PATCH 01/15] avformat/concatdec: Check in/outpoint for overflow
2023-10-02 12:03 ` [FFmpeg-devel] [PATCH 01/15] avformat/concatdec: Check in/outpoint for overflow Nicolas George
@ 2023-10-03 14:11 ` Michael Niedermayer
0 siblings, 0 replies; 22+ messages in thread
From: Michael Niedermayer @ 2023-10-03 14:11 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 790 bytes --]
On Mon, Oct 02, 2023 at 02:03:27PM +0200, Nicolas George wrote:
> Michael Niedermayer (12023-10-01):
> > Fixes: signed integer overflow: 91542414454000000 - -9154241494546000000 cannot be represented in type 'long'
> > Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-4739147999084544
> >
> > Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> > ---
> > libavformat/concatdec.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
>
> No objection.
will apply
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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] 22+ messages in thread
* Re: [FFmpeg-devel] [PATCH 01/15] avformat/concatdec: Check in/outpoint for overflow
2023-09-30 22:30 [FFmpeg-devel] [PATCH 01/15] avformat/concatdec: Check in/outpoint for overflow Michael Niedermayer
` (14 preceding siblings ...)
2023-10-02 12:03 ` [FFmpeg-devel] [PATCH 01/15] avformat/concatdec: Check in/outpoint for overflow Nicolas George
@ 2023-10-08 19:35 ` Michael Niedermayer
15 siblings, 0 replies; 22+ messages in thread
From: Michael Niedermayer @ 2023-10-08 19:35 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 763 bytes --]
On Sun, Oct 01, 2023 at 12:30:32AM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: 91542414454000000 - -9154241494546000000 cannot be represented in type 'long'
> Fixes: 51896/clusterfuzz-testcase-minimized-ffmpeg_dem_CONCAT_fuzzer-4739147999084544
>
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
> libavformat/concatdec.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
will apply patchset
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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] 22+ messages in thread