From patchwork Mon Apr 11 21:21:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 35265 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:671c:b0:7c:62c8:b2d1 with SMTP id q28csp1255699pzh; Mon, 11 Apr 2022 14:22:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw8jd13bE5RuJv/8fwAn6m9ZChm3FwARluE0GsmHmNRIOTczLQV4ka0IL00pw3eHQlX0eIJ X-Received: by 2002:a17:906:32d8:b0:6ce:d850:f79 with SMTP id k24-20020a17090632d800b006ced8500f79mr30852525ejk.414.1649712174809; Mon, 11 Apr 2022 14:22:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649712174; cv=none; d=google.com; s=arc-20160816; b=S5GdYZKPamL4LjRI8irTs944zbd7Q/U3dTffCwcpvQXjeeSRfDPU2YhrYnlsqGAm52 9XDUHUjPd4kXvpiL4m5UjVNeMsnCBEH20xxVOo11hAXf0dWp79TuHBaxnJiSjLvQyJMu crNW3ZPwBMVlP3gtZu2/aKmKYkvtJIC1GJVGTaXQFuMI+hrPXEHjesuHe+JwlZ9mB+8k OmizHBfVmXBP4TwDlqyqowNb9p9jMcKXfXnlXR5fGUN2PZFFqEjhRugDUXIJdmrbgwXr O6uuFhX8MkELUwMYg/ZYWsMBKQ0FBeUxbBAhf1eCVjL5MuuNrvkPxQEkpw3RsSdi1Gp0 Iyaw== 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=/Jj4+OAUtCLVXrtFWF8vAeexDn7umkIvDyBbi3xKAm4=; b=WCKNS5/xqx9mXlv+UAcMx1LNfhscPfwZN3Fg3efM9ESvWtqmP4fClqRlmPAaWvgRV8 dSnjko3rAGmRqPe5Sm88KQhVkXFXSjSwuw0xL49S5IaVsB85ZoNZHPU0gUbk5789G77F AV76uKj+Dsd8Mm6uWTsbQDNs2MhjoLgoSVVOcOmv1kAJtaA9ohhm+F8U1FB2RYwRaxad i10W9J+/TyBqIbAsHjFTrq4kLjnPIo/r75PFUHkSKZufQDJVr+tb7b6y9VFz+UyGBASV ESxTkoAnjrZQSSqeUDM5bKiR0lihnfPT8oBmnpdATafW7iHgnbyWfYF85XbDPtRVKq04 yGKQ== 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 i42-20020a0564020f2a00b0041d7b406027si2933233eda.175.2022.04.11.14.22.54; Mon, 11 Apr 2022 14:22:54 -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 2D21968B334; Tue, 12 Apr 2022 00:22:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-at03-3.mx.upcmail.net (vie01a-dmta-at03-3.mx.upcmail.net [62.179.121.153]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9B08068AC80 for ; Tue, 12 Apr 2022 00:22:41 +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 1ne1UZ-0003XX-3n for ffmpeg-devel@ffmpeg.org; Mon, 11 Apr 2022 23:22:35 +0200 Received: from ren-mail-psmtp-mg02. ([80.109.253.241]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id e1TGn9zsGSgGFe1UZn3kt8; Mon, 11 Apr 2022 23:22:35 +0200 Received: from localhost ([213.47.68.29]) by ren-mail-psmtp-mg02. with ESMTP id e1TMnIIr18eSWe1TMnKtkd; Mon, 11 Apr 2022 23:21:20 +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=KKE5sHJo c=1 sm=1 tr=0 ts=62549bdf a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=NEAV23lmAAAA:8 a=wUpTLJyOy0a5c4Df45kA:9 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Mon, 11 Apr 2022 23:21:18 +0200 Message-Id: <20220411212120.15692-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220411212120.15692-1-michael@niedermayer.cc> References: <20220411212120.15692-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfN0vugmXSLXLLxlVgR7rsHrUQKR+vB1xJLpyhI+BAVzAvujYWOP8n3pLKYdJkDBKBVz8p4O0BZwPqmMxCAOeY6eWr+o9NjiOZK0aoBlsPvoHxjDFhSz/ ObIJmmh3aLCwdR6DZgPVCpaLwCPN0fnMSTituhAtDXMxYMIlyH5wL5jI7/vb9aIqYrf3iBM4fDaCOA== Subject: [FFmpeg-devel] [PATCH 2/4] avformat/genh: Check sample rate 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: 2ydfQF21FVBo Fixes: signed integer overflow: -2515507630940093440 * 4 cannot be represented in type 'long' Fixes: 46318/clusterfuzz-testcase-minimized-ffmpeg_dem_GENH_fuzzer-5009637474172928 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavformat/genh.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavformat/genh.c b/libavformat/genh.c index b1c20718f6..a25d4d625a 100644 --- a/libavformat/genh.c +++ b/libavformat/genh.c @@ -67,6 +67,9 @@ static int genh_read_header(AVFormatContext *s) return AVERROR_INVALIDDATA; st->codecpar->block_align = align * st->codecpar->ch_layout.nb_channels; st->codecpar->sample_rate = avio_rl32(s->pb); + if (st->codecpar->sample_rate < 0) + return AVERROR_INVALIDDATA; + avio_skip(s->pb, 4); st->duration = avio_rl32(s->pb);