From patchwork Sat Sep 30 22:30:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 44060 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1204:b0:15d:8365:d4b8 with SMTP id v4csp599315pzf; Sat, 30 Sep 2023 15:32:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEdZM9LMrc1+ZISQe5u657taTt8Olv412+iej37/DSBhfcTH5p4btAv4plj3Azp9iq/2VI9 X-Received: by 2002:a05:6402:1f0e:b0:530:7ceb:334 with SMTP id b14-20020a0564021f0e00b005307ceb0334mr7718706edb.3.1696113167504; Sat, 30 Sep 2023 15:32:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696113167; cv=none; d=google.com; s=arc-20160816; b=L8qRoKcadNAZIylkruYYB4Bs080f9jnWNm2ItgDiY2rjt2vDJQlq0xTRVsRAZp95Ij jhYIuuBdztVs8ipgsDQYAstjkMjk0QIawyrJeVl8PuxsPI5gEsflLYlpkTF5sPRa7EdW dewjZxxZveNJXoSu7RDQSJ3CAe4b8jWj2X7BieQkyXs0Ew8VXbJGtAA2V34CrWNkqwkc t0ZOZaE3UWKUwOuwEua3xaI0Bd83jyyDDhFUkImHWZ/qn/YNPYVu/EjEQApoaOp0fh7N BJ6n2ydw058CaS92G9j5ns9Kih2Y+WjvKprLsEO3+rdJ/+ITCanKg1f1H/LQNJra2OS1 KjRA== 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=thtinLeQgFPbZcOEj7D0JFfdkzZZyED2lUmIvieybyQ=; fh=e5zN9xSzcxLA6bGo3lF+CqTbY/oLwzApV03EO/RBfgQ=; b=TYzefJlnPA/xbOiAV2jjUqDYl2EdC2jkgZCGt7eztrH2e6ARnhJYkf5CbApqDe1v9F oUzTM5GCWjPJDybnntCBue0AoARPBa4g4NPjp1zqiuixTZIscHRrqBOkSUCC+A0neMZY e0IT15yiTPp6U83sLHO2N55Lk1iZ+nDSdH27UEFQWdKyN7+kAjBe10g/hKqklqmoKQ4X u/zkbMu+Faf9p7QoO48zYBsu5tUNHIrBnJIxRFF1yTjZLv1/kIlhZEz8OUk9Wgc3NNR+ Vh3xxh+eNaoAXI6WIPI+qtCoa6C7tphgSDlecXZ7LCp3rHRGuWttV9cudJboyY+VG+Tx 44Ew== 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 dy21-20020a05640231f500b005346627df53si6856372edb.661.2023.09.30.15.32.47; Sat, 30 Sep 2023 15:32:47 -0700 (PDT) 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 80A9268CD4E; Sun, 1 Oct 2023 01:31:08 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [217.70.183.193]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 44FEC68CD55 for ; Sun, 1 Oct 2023 01:31:01 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 93973240002 for ; Sat, 30 Sep 2023 22:31:00 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 1 Oct 2023 00:30:46 +0200 Message-Id: <20230930223046.22896-15-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230930223046.22896-1-michael@niedermayer.cc> References: <20230930223046.22896-1-michael@niedermayer.cc> X-GND-Sasl: michael@niedermayer.cc Subject: [FFmpeg-devel] [PATCH 15/15] avcodec/h264_parser: saturate dts a bit 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: ENg3F5yJIWZI 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 --- 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)