From patchwork Sat Sep 17 21:15:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 37990 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3b1c:b0:96:9ee8:5cfd with SMTP id c28csp389402pzh; Sat, 17 Sep 2022 14:16:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5+wjOI5dm4MZ2oceb4WVKocJQf/ayuPUMQvJdbP1bY5XoKfQYnrYnzVyhzd5WSX15RjXUY X-Received: by 2002:a05:6402:5cb:b0:452:e416:2bc4 with SMTP id n11-20020a05640205cb00b00452e4162bc4mr9286797edx.114.1663449398494; Sat, 17 Sep 2022 14:16:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663449398; cv=none; d=google.com; s=arc-20160816; b=vuOtLgTsDKJveIYoj+wRc9foiZlgVBreg6+Dv+VzE0kBDuwopvxziA9g2PxwC5MvoZ KgyMAc8duXawlN930vrZilByo0CIoU2TXNLd3Ol3yV4ik5IDTcAEujCgGLegq+LMmNiC w8ullzdGlSqM0bpLIhUminRti4MBtGBYtDJjOQIOCW/46Lbv65FrAjglY3H4XXtEwooh giOdv1TTdRry7wYT3PFw4skm+OnMg2mM/VAyYL2yg1pxDQOqmTdvHwerJVwiLPJRXMQl 9UdkVURP5/fHacidDWqy1dhH6W3dXoblJLQNVnbbaLN0GNs6ZEqmxPkNG2jSyY0qeYtF /XeA== 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=ZwWAVpfxnWQ7PvvdHhNv3xB2xHC4cvXog8Ijwq5x/EY=; b=quYtEycNNE/psE5LthWp72q9+Kw62w+8xB2GxhY7+SHo05z61QJSoQQrwNx4yzRBeh A7AD0rGjzUnl/MCRSqTHFcdfKrIFDepkvGpypqVJ2bsjr+g6F889y/165qJSFvfDkBoK hv4hVShyQ4NBUYGIqb5PiXm8a9SkUnMq1or8g2Rc+P48oj9seZw+ztZSKX2J8B99fwiU 6ySds8oEUWfwwTg+3vURasOWgf1FM5F5w8R+7pfT0lEJMxt1KXkLGZimG8ClM2f7/tHe FYcG82x5qLutXWWoRCXm9uUS7i0z8kvdQ6ZChWfOCKKL6bXxzgpG3JK5XcSaf8TSAqxR vrXg== 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 gt16-20020a1709072d9000b0077f0a70e44dsi16899106ejc.200.2022.09.17.14.16.38; Sat, 17 Sep 2022 14:16:38 -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 416D868BBB4; Sun, 18 Sep 2022 00:16:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-at03-1.mx.upcmail.net (vie01a-dmta-at03-1.mx.upcmail.net [62.179.121.151]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 46FA768BA02 for ; Sun, 18 Sep 2022 00:16:00 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-at03.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1oZfAN-00DrNV-3G for ffmpeg-devel@ffmpeg.org; Sat, 17 Sep 2022 23:15:59 +0200 Received: from ren-mail-psmtp-mg01. ([80.109.253.241]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id Zf9moPPmW8s8UZfANoEt8B; Sat, 17 Sep 2022 23:15:59 +0200 Received: from localhost ([213.47.68.29]) by ren-mail-psmtp-mg01. with ESMTP id ZfAMoibKrOG5ZZfANom24R; Sat, 17 Sep 2022 23:15:59 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 213.47.68.29 X-CNFS-Analysis: v=2.4 cv=KJo5sHJo c=1 sm=1 tr=0 ts=6326390f a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=NEAV23lmAAAA:8 a=ivyqkYbKNu5qN0FXvq8A:9 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 17 Sep 2022 23:15:52 +0200 Message-Id: <20220917211557.11547-4-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220917211557.11547-1-michael@niedermayer.cc> References: <20220917211557.11547-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfKq4dzuArM76/NQYEO8esUrYd/wGR+o9H8JdspmBJiwZVS5u8IOHkzEliDeGgbskw6qdOkQdQMnxac44YCD8OSJVWd12Y6q+9JjT1GToiUWUgQ9aVCDI NTj+Q9MGVvD6Xh1ZoxrR6atq73/rhbjeMlZ1AhGI+FccM1TXkXclkcn2ym/hyq/tbd7FVAUWyH4+Vw== Subject: [FFmpeg-devel] [PATCH 4/9] avformat/cafdec: Check that nb_frasmes fits within 64bit 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: z61IHSzBUj9Y Fixes: signed integer overflow: 1099511693312 * 538976288 cannot be represented in type 'long' Fixes: 50993/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-6565048815845376 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/cafdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index d5b8c38c25c..e0a9031cb80 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -387,7 +387,7 @@ static int read_header(AVFormatContext *s) found_data: if (caf->bytes_per_packet > 0 && caf->frames_per_packet > 0) { - if (caf->data_size > 0) + if (caf->data_size > 0 && caf->data_size / caf->bytes_per_packet < INT64_MAX / caf->frames_per_packet) st->nb_frames = (caf->data_size / caf->bytes_per_packet) * caf->frames_per_packet; } else if (ffstream(st)->nb_index_entries && st->duration > 0) { if (st->codecpar->sample_rate && caf->data_size / st->duration > INT64_MAX / st->codecpar->sample_rate / 8) {