From patchwork Mon Nov 21 23:58:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 39384 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp2622372pzb; Mon, 21 Nov 2022 15:58:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf7pk/UPXsjoz6f+66EXGI83uybUkwaQPmbObUt991pd3g+jPdV7Ukunw5CKot8hMfDiFLS4 X-Received: by 2002:a17:906:3e18:b0:78d:8d70:8bf8 with SMTP id k24-20020a1709063e1800b0078d8d708bf8mr2207521eji.15.1669075133272; Mon, 21 Nov 2022 15:58:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669075133; cv=none; d=google.com; s=arc-20160816; b=JOvXoohmRtTfgmYwdTeEjp8VZRbvLA5wTp02pFxs8rZaKSIFeDMChry5nC3J/aeTIN rv3ApgNSEahknVvQwM4U5BQYPWGey4QxJDSViGruOuts6u1BrPdT+rctOGx09M+zL2/u K/9BYhXbbmtfqEI6yJBTzt0PLIUykWvfnvJagqs4NK9lTYKi7b6NV/tChU6KMIYTrRla 9KYax3258Dc56BfDmn9y/sdnj3NvaO0zt242HOgQ+JCv/4stcLP1S1kaMFKZlWNP0GN0 7nAmlxlosa953vKl+3di2lRJ5F2LrcrHSI07gsxMA9ulqsuoeGOhRkNaR6XmSOdogV4S 7SlQ== 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:references:in-reply-to:message-id:date :to:from:delivered-to; bh=xxWq/MuzSz5vvoHw55R11JSiwCYvC5QeufG8CAkp9BE=; b=mrlqK4mBsic8PACyEU4FMlKRYyBC1th26sOtIqu3ikUkH8NYwFhmgZGP/bj0TPAvWj vKKY2FF/IZ7xsOmvXG8BZT0+jBo3D0BuLjt1dbmW8EfnX2tKvd853QaFc8HdvKHBW+XH O9lRLp2bXyjc5m3xE8GtDXU7eIO44a9qEiH1Vupd1wus5fpJcWwOebHZTl+fW8rIaPHl wzmgMyRcT64uoNM8KPAQwiueCR8wBMU0509GauKKtfT3i0w18BBcRhXYAizmSOs/6Gh4 8R4iYH7q9VcNtH8PIe1JO1aiAumjRkaNnHlT9Qfkm/gqFjTLZkk70z5d98WV+66RZ3cV AWWg== 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 xe8-20020a170907318800b007ae9bc0b977si10895225ejb.486.2022.11.21.15.58.52; Mon, 21 Nov 2022 15:58:53 -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 86E4068BB37; Tue, 22 Nov 2022 01:58:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0EC4A68BAC7 for ; Tue, 22 Nov 2022 01:58:26 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 34AAAFF803 for ; Mon, 21 Nov 2022 23:58:25 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 22 Nov 2022 00:58:23 +0100 Message-Id: <20221121235823.28468-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20221121235823.28468-1-michael@niedermayer.cc> References: <20221121235823.28468-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/dts2pts_bsf: Eliminate some 64bit corner cases 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: EmDaFB64wkS0 Fixes: negation of -2147483648 cannot be represented in type 'int'; cast to an unsigned type to negate this value to itself Fixes: 53364/clusterfuzz-testcase-minimized-ffmpeg_BSF_DTS2PTS_fuzzer-4693772269387776 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, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/dts2pts_bsf.c b/libavcodec/dts2pts_bsf.c index 8142562d2c..522d5e1eb0 100644 --- a/libavcodec/dts2pts_bsf.c +++ b/libavcodec/dts2pts_bsf.c @@ -301,15 +301,15 @@ static int h264_filter(AVBSFContext *ctx) if (output_picture_number != h264->last_poc) { if (h264->last_poc != INT_MIN) { - int diff = FFABS(h264->last_poc - output_picture_number); + int64_t diff = FFABS(h264->last_poc - (int64_t)output_picture_number); if ((output_picture_number < 0) && !h264->last_poc) h264->poc_diff = 0; - else if (FFABS(output_picture_number) < h264->poc_diff) { + else if (FFABS((int64_t)output_picture_number) < h264->poc_diff) { diff = FFABS(output_picture_number); h264->poc_diff = 0; } - if (!h264->poc_diff || (h264->poc_diff > diff)) { + if ((!h264->poc_diff || (h264->poc_diff > diff)) && diff <= INT_MAX) { h264->poc_diff = diff; if (h264->poc_diff == 1 && h264->sps.frame_mbs_only_flag) { av_tree_enumerate(s->root, &h264->poc_diff, NULL, dec_poc);