From patchwork Sat Aug 14 15:08:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 29510 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp522597iov; Sat, 14 Aug 2021 08:14:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzON7B8Z8xSq8cSPq9WIbQQw5EY11AFT5SK7RdivCV4NZ7pyDljXlHWii0SiXjb8rUTK3AO X-Received: by 2002:a05:6402:5192:: with SMTP id q18mr9488697edd.149.1628954060655; Sat, 14 Aug 2021 08:14:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628954060; cv=none; d=google.com; s=arc-20160816; b=c1Z5rGnkZ8ZCFvBvzQ6MDfJR4PeBgEg+BAQqpbBMQW5MVH+hfJedSicrxL5tPhvqor kDYD8Jtvbsk1XBk9sbyHsMzviHS3Oqj7cUxJkN5lrNiDqeXL6Y/LEC5ee3fy5T15LGwN DuEPNPy6sTFL+piXIWJq4zP8kyJnwNFNnwEKLwLqFNi2V6Gn5k47Ek/b5cJvu3LFW8Wi typhGYdc0IIlSNgmA50f110OA0kgdPKIBE5ppd7PB9nggV4d1ECT4UFbU1kqfGxhmGlr R2t+RF+e2dhh30F54NuMValbd10bo584ZxXv75QZvNw4fwRsnhvNyc29hJHqQPAeRS1l g+Jg== 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=uavAB/KEv42l++c2NcWcWKOM25W8Cwj58LOsp8ao5aY=; b=JfqE6I63iJ7dY5ILjIoqJMJdY3h/Be6p2cYLQQFb2TT1/u6dwnydBoGAE2H7IqMMU8 /Z86AYft9cIiHs0kspZvX9bpAF6l2ICsFMV6caEjCO+gerkY5TW0vKB3OTFPUHksBUnG qoVYW2tgkS0ccoyS5UcDlIL+9xIxNTrZlpP6LH9rk7lojLxTuCNs9qDfsOfkN63ueMo4 9cJz+N9kkUZtU7gNLf1iXHb9OUkWG5xs0FuRHKkH0lpgIKNUfYemes5uOAKPrqJ+x17M 7YfcU/q43dqrUMJlIyYZZV84pPkA3XaV6AZQsrIhyRYQZyiKCtbqfTXKmAUPwtME/2F8 w8YQ== 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 ne8si5772231ejc.243.2021.08.14.08.14.19; Sat, 14 Aug 2021 08:14:20 -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 3FC5168A63F; Sat, 14 Aug 2021 18:14:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-dmta-pe05-3.mx.upcmail.net (vie01a-dmta-pe05-3.mx.upcmail.net [84.116.36.13]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 80A166899E0 for ; Sat, 14 Aug 2021 18:14:09 +0300 (EEST) Received: from [172.31.216.235] (helo=vie01a-pemc-psmtp-pe12.mail.upcmail.net) by vie01a-dmta-pe05.mx.upcmail.net with esmtp (Exim 4.92) (envelope-from ) id 1mEvHR-00G9TK-0o for ffmpeg-devel@ffmpeg.org; Sat, 14 Aug 2021 17:09:01 +0200 Received: from localhost ([213.47.68.29]) by vie01a-pemc-psmtp-pe12.mail.upcmail.net with ESMTP id EvGTm9Iz5ljeHEvGTmywjK; Sat, 14 Aug 2021 17:08:01 +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.3 cv=BoHjPrf5 c=1 sm=1 tr=0 a=2hcxjKEKjp0CzLx6oWAm4g==:117 a=2hcxjKEKjp0CzLx6oWAm4g==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=ZZnuYtJkoWoA:10 a=nZOtpAppAAAA:20 a=wdkXCKs3Vz8aPe84FHoA:9 a=1fhp2MxaeJtTNGEnv6mo:22 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sat, 14 Aug 2021 17:08:00 +0200 Message-Id: <20210814150800.13974-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210814150800.13974-1-michael@niedermayer.cc> References: <20210814150800.13974-1-michael@niedermayer.cc> X-CMAE-Envelope: MS4wfPQBugdqrVk+hfEbRNV+ud15P4ksetv1O87d4URdg1lMi3Q5LVCsu+lpUxs1rGp/vuJRj0P8M2DyKlxD0MaziK8BNbZdxaN47MCR6cg8EiVF1P9TfrvU 1WbqwdEWDG9k2kUfViIEeuuGdCXduua5um7ZWF2QatKs8F4dWyDtEaDR Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/h264_parser: fix nalsize parser 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: zF5+E5igU+YH Fixes: left shift of 16711968 by 8 places cannot be represented in type 'int' Fixes: 36601/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-6581933285965824 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/h264_parser.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/h264_parser.c b/libavcodec/h264_parser.c index d3c56cc188..22111c62a2 100644 --- a/libavcodec/h264_parser.c +++ b/libavcodec/h264_parser.c @@ -86,7 +86,7 @@ static int h264_find_frame_end(H264ParseContext *p, const uint8_t *buf, int nalsize = 0; i = next_avc; for (j = 0; j < p->nal_length_size; j++) - nalsize = (nalsize << 8) | buf[i++]; + nalsize = ((unsigned)nalsize << 8) | buf[i++]; if (nalsize <= 0 || nalsize > buf_size - i) { av_log(logctx, AV_LOG_ERROR, "AVC-parser: nal size %d remaining %d\n", nalsize, buf_size - i); return buf_size;