From patchwork Wed Oct 25 22:02:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 5692 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.90 with SMTP id m26csp109600jah; Wed, 25 Oct 2017 15:03:23 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TdXUwQnaZgLWGYFoamEScXGmFcTV63PC59p0yeIL6CDuHgSYcBQVukf2TsffhVGZ7RbQrx X-Received: by 10.28.71.90 with SMTP id u87mr2889100wma.91.1508969003492; Wed, 25 Oct 2017 15:03:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508969003; cv=none; d=google.com; s=arc-20160816; b=dqJPru6CrqUgS3RCvLnMKDWz0ERV0P3ELk7SL4m3PmXykS/gdwG9Cj32OeQ7RIvgUu vo6SXlN7MPVSszpqhfqTsHwusS196xC9vnFb/XBMf9Kfq3mxodDO4g/sbHBhLczC7pPN 8V9jH6ravjPJMWcT2IyQYoV4KNdHziZ/sWbsyhnK6yTVYnEoK/sDRTW+9CkQGIyUp6XW Q9cxgqt2/rEzambceoACLv25Y1dcogTQRbLCJx2wEqq+Z5tTTE8NbssTpXoXs0WjctaJ l2RgkfdCnEKH1FfZIqNXxSe0iLFqtffJZsqyjcu0N9gwTuOf4SNFhdszb8lLrlBY+BiK scHg== 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:arc-authentication-results; bh=wioIvn6j9tBpxpoKU7q8bwoIB96ZSSga9PmkqLgqBkA=; b=m6BENw11UPyZLcnvlq4wbGUtUdmupi5N0SNhnPX+Z7Ml4Yuu4LYYQ7TUlz1RzO18DV 67QdnLWKE5kS4OFEYRQ3lSR0Jx4rrv/A+Mq21POvScc+sNUfp5XdjEky5GTRO8pCO58W yUQVj84kn4WJkGGKI7KzwFtodpv0kh7vlGHf0jReQ7vKRI9gYGMfffWMIzYKikHrCRxx erTDzqTPYMpqPjtgW8T6BIiG/2QgJmc/9BgHlJG8afRdHmPFXIifbWM+O/h4TeYcmXhH 8dHl3P8+tycCMyVHM8f0vIFRK/eKrzmZtg0rlnTqS9wMGaxVVb70KhuuRqvTlL1rEZn8 Wo8g== 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 v65si2616032wmd.50.2017.10.25.15.03.17; Wed, 25 Oct 2017 15:03:23 -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 B3B5368A535; Thu, 26 Oct 2017 01:03:08 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from vie01a-qmta-pe02-1.mx.upcmail.net (vie01a-qmta-pe02-1.mx.upcmail.net [62.179.121.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 448A268A3AA for ; Thu, 26 Oct 2017 01:03:03 +0300 (EEST) Received: from [172.31.218.48] (helo=vie01a-dmta-pe06-3.mx.upcmail.net) by vie01a-pqmta-pe02.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1e7TlW-0001pO-Hu for ffmpeg-devel@ffmpeg.org; Thu, 26 Oct 2017 00:03:10 +0200 Received: from [172.31.216.43] (helo=vie01a-pemc-psmtp-pe01) by vie01a-dmta-pe06.mx.upcmail.net with esmtp (Exim 4.88) (envelope-from ) id 1e7TlQ-0001Jh-PM for ffmpeg-devel@ffmpeg.org; Thu, 26 Oct 2017 00:03:04 +0200 Received: from localhost ([213.47.41.20]) by vie01a-pemc-psmtp-pe01 with SMTP @ mailcloud.upcmail.net id Ry2z1w00w0S5wYM01y302Y; Thu, 26 Oct 2017 00:03:00 +0200 X-SourceIP: 213.47.41.20 From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Thu, 26 Oct 2017 00:02:57 +0200 Message-Id: <20171025220257.7790-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171025220257.7790-1-michael@niedermayer.cc> References: <20171025220257.7790-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/2] avcodec/jpeglsdec: Check for end of bitstream in ls_decode_line() X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" Fixes: 1773/clusterfuzz-testcase-minimized-4832523987189760 Fixes: Timeout Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer --- libavcodec/jpeglsdec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/jpeglsdec.c b/libavcodec/jpeglsdec.c index cb2f89a88c..5308b744df 100644 --- a/libavcodec/jpeglsdec.c +++ b/libavcodec/jpeglsdec.c @@ -233,6 +233,9 @@ static inline void ls_decode_line(JLSState *state, MJpegDecodeContext *s, while (x < w) { int err, pred; + if (get_bits_left(&s->gb) <= 0) + return; + /* compute gradients */ Ra = x ? R(dst, x - stride) : R(last, x); Rb = R(last, x);