diff mbox series

[FFmpeg-devel,1/2] avcodec/dts2pts_bsf: Avoid searching for poc == INT_MIN-1

Message ID 20221206234808.10024-1-michael@niedermayer.cc
State Accepted
Commit 125e01d6cc111027c0c5f5fe6a787154c9a96006
Headers show
Series [FFmpeg-devel,1/2] avcodec/dts2pts_bsf: Avoid searching for poc == INT_MIN-1 | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer Dec. 6, 2022, 11:48 p.m. UTC
Fixes: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
Fixes: 53876/clusterfuzz-testcase-minimized-ffmpeg_BSF_DTS2PTS_fuzzer-6569754750222336

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/dts2pts_bsf.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

Comments

Michael Niedermayer Dec. 25, 2022, 6:37 p.m. UTC | #1
On Wed, Dec 07, 2022 at 12:48:07AM +0100, Michael Niedermayer wrote:
> Fixes: signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'
> Fixes: 53876/clusterfuzz-testcase-minimized-ffmpeg_BSF_DTS2PTS_fuzzer-6569754750222336
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/dts2pts_bsf.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)

will apply patchset

[...]
diff mbox series

Patch

diff --git a/libavcodec/dts2pts_bsf.c b/libavcodec/dts2pts_bsf.c
index 522d5e1eb0..48612e59db 100644
--- a/libavcodec/dts2pts_bsf.c
+++ b/libavcodec/dts2pts_bsf.c
@@ -461,9 +461,10 @@  static int dts2pts_filter(AVBSFContext *ctx, AVPacket *out)
                 poc_node = av_tree_find(s->root, &dup, cmp_find, NULL);
             }
         }
-    } else {
+    } else if (s->eof && frame.poc > INT_MIN) {
         DTS2PTSFrame dup = (DTS2PTSFrame) { NULL, frame.poc - 1, frame.poc_diff, frame.gop };
-        if (s->eof && (poc_node = av_tree_find(s->root, &dup, cmp_find, NULL)) && poc_node->poc == dup.poc) {
+        poc_node = av_tree_find(s->root, &dup, cmp_find, NULL);
+        if (poc_node && poc_node->poc == dup.poc) {
             out->pts = poc_node->dts;
             if (out->pts != AV_NOPTS_VALUE)
                 out->pts += poc_node->duration;
@@ -480,7 +481,8 @@  static int dts2pts_filter(AVBSFContext *ctx, AVPacket *out)
                        poc_node->poc, poc_node->gop, poc_node->dts, poc_node->duration);
         } else
             av_log(ctx, AV_LOG_WARNING, "No timestamp for POC %d in tree\n", frame.poc);
-    }
+    } else
+        av_log(ctx, AV_LOG_WARNING, "No timestamp for POC %d in tree\n", frame.poc);
     av_log(ctx, AV_LOG_DEBUG, "Returning frame for POC %d, GOP %d, dts %"PRId64", pts %"PRId64"\n",
            frame.poc, frame.gop, out->dts, out->pts);