From patchwork Sun Dec 25 18:28:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 39749 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp2221869pzb; Sun, 25 Dec 2022 10:28:24 -0800 (PST) X-Google-Smtp-Source: AMrXdXscS2MUsgdOAxKpr2fayUicJrbdXZWhagfzLqyLaAtQlkUncuXya5lmay0pwbnENgJ5Mxk1 X-Received: by 2002:a17:906:7254:b0:7ad:bc7e:3ffd with SMTP id n20-20020a170906725400b007adbc7e3ffdmr15290826ejk.42.1671992903777; Sun, 25 Dec 2022 10:28:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671992903; cv=none; d=google.com; s=arc-20160816; b=qY7GaB7QVt8VDxTbyhwKdaMLcwB/rXDsxu6jI3EcBOt4Gnvt6O79Wd3FgrhDBc0ijc EDazmGyjWTpYtfeVImjfxGp83jb9CksXtBOeH6SQkjtjEsXlEzoCzhZ3BMDhS259cNRK BffSh6Jr79wVJ0B0MS1NBOmbKq0revKPTiPtbzLS8LtzAaoRqAShH1wKFsGHwLII4ywl dD+Fbqv9SnpR8f9pxTAsBwdbnV5VW2UtBFhHnMHWoFolEDy6VaxVBBNOfEz9Hdh6BCbC NeLm9WHH/EMa5qcPBUMglImnLAH4VGSsBtpb3aFgiUehL8FlPZvd9jVCHkQDVWCx3mrP tUdQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:message-id:date:to:from:delivered-to; bh=oDoZtgM1962AIhMUSID0zdL9U/3Q8OIPVWiPlNT6KjQ=; b=EmicjEUGqcs2GdKMkRiQJhLUSIfrQaY7kJf1K2MtFISpAWyZ74B8dOjJ9x+hR8uQB9 kiJBZVfy1Ujo5IJ2q4a/DVBL2E5gSc1JSNTdz17g/72GDBJEUHuEpcB2Cu53gR8EdViv l4KTSty2CAVIGhqRk6q4Kv+id+GQSye4GVkiHQ1zkleBW+khwWdXhAeSg1T4MeVymZ7r NEbGBrA7rQbElGmmgSTElR3u7WYQ3IWxe24lPnurA0VZhSj6I6OJJFjXPdpaYEGV8/Vz tlOpgy+IvKjqXsjOQkTrmX+sqpfuREdC2yd72vaNHfmrUY5fn9IXah/PHaLBLbQ9MW4o IsrA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id wz2-20020a170906fe4200b0082b45653622si6972255ejb.333.2022.12.25.10.28.23; Sun, 25 Dec 2022 10:28:23 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BD2AC68B7E9; Sun, 25 Dec 2022 20:28:20 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5BEE9680B98 for ; Sun, 25 Dec 2022 20:28:14 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 8582B1C0005 for ; Sun, 25 Dec 2022 18:28:13 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 25 Dec 2022 19:28:12 +0100 Message-Id: <20221225182812.18238-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH] avcodec/dts2pts_bsf: Avoid poc overflows in cmp_find() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: CO0wq0ayx9Sf Fixes: signed integer overflow: -2147483648 - 5 cannot be represented in type 'int' Fixes: 54242/clusterfuzz-testcase-minimized-ffmpeg_BSF_DTS2PTS_fuzzer-472928339243827 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/dts2pts_bsf.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/dts2pts_bsf.c b/libavcodec/dts2pts_bsf.c index 48612e59db..60bec91f99 100644 --- a/libavcodec/dts2pts_bsf.c +++ b/libavcodec/dts2pts_bsf.c @@ -90,9 +90,11 @@ static int cmp_insert(const void *key, const void *node) static int cmp_find(const void *key, const void *node) { - int ret = ((const DTS2PTSFrame *)key)->poc - ((const DTS2PTSNode *) node)->poc; + const DTS2PTSFrame * key1 = key; + const DTS2PTSNode *node1 = node; + int ret = (key1->poc > node1->poc) - (key1->poc < node1->poc) ; if (!ret) - ret = ((const DTS2PTSFrame *)key)->gop - ((const DTS2PTSNode *) node)->gop; + ret = key1->gop - node1->gop; return ret; }