From patchwork Mon Jun 19 23:04:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 42232 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:be15:b0:121:b37c:e101 with SMTP id ge21csp992103pzb; Mon, 19 Jun 2023 16:04:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4crHc6+JstEmHHwRjn0WviHDd9Oz6IxoHsy3dBR7Xxi4ngVqbrRZ3KK0dE2i1nRoWCsF0l X-Received: by 2002:a17:906:7943:b0:987:e23f:6d7a with SMTP id l3-20020a170906794300b00987e23f6d7amr6364454ejo.25.1687215878392; Mon, 19 Jun 2023 16:04:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687215878; cv=none; d=google.com; s=arc-20160816; b=a1mCLEhK9P6ATJ1S0nQd40Mb9nSNxy5g+G8botmIzj4LN9P+1fLG/YJ2ilyTTRK9cu GY7U/UQ98sUHvWHrpGPVqXueciGFEChWlQ+PUCuDi1PreHbxg5bgB1qtNxfnLBKdPtFm MfhwMftAUHLn6PKTKeqqgBgxUKVTK+8/Sn0Vph0kZoNNoQtokAqwJC00phVObYzne8xE 3C/qvi5Mn2iGJNDq8EU+F4453Fa4FE63+2dgZ6qtLNMm+OgEFXSOsU/kRKbaYTPHfy6G JxSeOl9fNq/SZFTlyexeKFZsBMltoKvzsS8FgkLw423BJ81PEEOLoutjjJ3AbqAew2yH q8Hg== 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:message-id:date:to:from:delivered-to; bh=MbNCBKdE93CF23t9u8/xx7cEXw/JycbLKthURK4DRZE=; b=HWp7oOToSXBEmPE+V0VUxFfhtNbvy+osNLOCr2JUlkFoc8mb78pmZLzjcWbpLPVbBw Sj8rG0F/oVS+RUdR/U+T+HIL6iGATWRYzWeyRRzG7lY6oP7JFTA9nN6RJlX1Az/QharC TUjIpk5C1yBQ5Oz782gFW9jS2cVTzsbY1ho0LL7qKiFqoBEKD4TSgXlIq1WzHTtotAuM jDIqsEIh9+zBPr9okgyO5WEE+EkFwwpOO3PkTgw2JG2vKlJyl4gpq+A740Epnu4r3MUh k/hO38wxzCxS/yvAcbcHNip5z3VyH7WXmbskcU3ljZJ9xLKzeN348anZVA5l57DE55oP qyvA== 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 j5-20020a1709066dc500b009880dc6b9b3si288268ejt.326.2023.06.19.16.04.37; Mon, 19 Jun 2023 16:04: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 84D3068AAB3; Tue, 20 Jun 2023 02:04:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-01-1.mymagenta.at (mail-01-1.mymagenta.at [80.109.253.246]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DAD9368AAB3 for ; Tue, 20 Jun 2023 02:04:26 +0300 (EEST) Received: from [192.168.232.136] (helo=ren-mail-psmtp-mg02.) by mail-01.mymagenta.at with esmtp (Exim 4.93) (envelope-from ) id 1qBNv7-00Efch-57 for ffmpeg-devel@ffmpeg.org; Tue, 20 Jun 2023 01:04:25 +0200 Received: from localhost ([84.115.40.24]) by ren-mail-psmtp-mg02. with ESMTP id BNv8q1jN7bZLDBNv8qup9v; Tue, 20 Jun 2023 01:04:26 +0200 X-Env-Mailfrom: michael@niedermayer.cc X-Env-Rcptto: ffmpeg-devel@ffmpeg.org X-SourceIP: 84.115.40.24 X-CNFS-Analysis: v=2.4 cv=Ufwy9IeN c=1 sm=1 tr=0 ts=6490defa a=4thelYDX6rwh+ygQwvsI+Q==:117 a=4thelYDX6rwh+ygQwvsI+Q==:17 a=MKtGQD3n3ToA:10 a=1oJP67jkp3AA:10 a=GEAsPZ9sns4A:10 a=NEAV23lmAAAA:8 a=IAIIEyv82i-gi4R8DAoA:9 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Tue, 20 Jun 2023 01:04:22 +0200 Message-Id: <20230619230424.30270-1-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 X-CMAE-Envelope: MS4xfK68d2bRh0p05P1NP/p4nKlrtHsUGSB0lGq8ADu4k6bL84CZwD2mVPXL6WDi0JP2kAzGjuvsGX+fKtNqo+RSsou3EWiCOw9xttY1rJ3FD56oEH0ma/L/ o9Erhs6BsNEO95xmrtOyXq6McSN7Q3qpGTZq/QzTs81U7o4Mli5DLxdRV4kxVp73FrWOW9u0DeRKoA== Subject: [FFmpeg-devel] [PATCH 1/3] avcodec/huffyuvdec: avoid undefined behavior with get_vlc2() failure 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: HhbnEONKUk6d Fixes: left shift of negative value -1 Fixes: 59889/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HUFFYUV_fuzzer-5472742275940352 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/huffyuvdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c index 8ba67bbdeb..1a7690da94 100644 --- a/libavcodec/huffyuvdec.c +++ b/libavcodec/huffyuvdec.c @@ -755,7 +755,7 @@ static void decode_plane_bitstream(HYuvDecContext *s, int width, int plane) } } if( width&1 && get_bits_left(&s->gb)>0 ) { - int dst = get_vlc2(&s->gb, s->vlc[plane].table, VLC_BITS, 3)<<2; + int dst = (unsigned)get_vlc2(&s->gb, s->vlc[plane].table, VLC_BITS, 3)<<2; s->temp16[0][width-1] = dst + get_bits(&s->gb, 2); } }