From patchwork Tue Nov 8 22:36:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Cadhalpun X-Patchwork-Id: 1352 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.90.1 with SMTP id o1csp1940709vsb; Tue, 8 Nov 2016 14:37:09 -0800 (PST) X-Received: by 10.194.87.7 with SMTP id t7mr12165877wjz.196.1478644629659; Tue, 08 Nov 2016 14:37:09 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l5si19025642wml.40.2016.11.08.14.37.09; Tue, 08 Nov 2016 14:37:09 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@googlemail.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; dmarc=fail (p=QUARANTINE dis=NONE) header.from=googlemail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B59DF689D2B; Wed, 9 Nov 2016 00:37:03 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f66.google.com (mail-wm0-f66.google.com [74.125.82.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 10316689CDD for ; Wed, 9 Nov 2016 00:36:57 +0200 (EET) Received: by mail-wm0-f66.google.com with SMTP id u144so25569386wmu.0 for ; Tue, 08 Nov 2016 14:37:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:subject:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=TcMyvt7SzBDo+D60xULoXHTKMUK7gWxl6oi524moFYg=; b=0NUSNulaIk111NyJGWjSPgFCEVpu+oAf3BFAjvfyraavebWzoWVU7cll0KCBESIkoL 7lK14AwNZVzMiBmENRidYYc7Pjf9FvxkE/6TzUPSVv6fLCeHUiCa2XsNpdRW9jO6cSwE gbCzOgZc39ThajlP406mDdfVlx0EKgL1hqgLXpNFCTo39eQN/fTWmypyM7X9uvbQDbK3 Sqr/jEbo92pg/yqmVw07BGURsW/lsGESdWvnhCiAQf0SehNDjygCxKT52HNBNiqLYbOR UP6OaeX0sYg/sAYumjXRdtqCYYQY0BesLbGS4UbKigmrzb6GNcUYYpiDYVhjctxARizM /kLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=TcMyvt7SzBDo+D60xULoXHTKMUK7gWxl6oi524moFYg=; b=g9+zCczBfaVUtXb4lJ2sFon4LXj/Q1S4bqsEv/HUoBEi3j3+XlW7Un8NHXS7dCQ7tp NRqNLG9lEwI0nXn22poEIWwMJ583O6ROT8r3vjD5NZPrLeG+yDtGZi6aCJjhT1oimr1Q jobSbS2MPabPy9mVKaTm6LUCbxnshWQlqa0JZW4U78Xl3iAYTpFjvf6OkDXiGQ9rJPhG p0Vr7stNjH9H6zv1VO3gXs0AHNeYko0oIlmSlyPotO8Bn7jExDbHBxTA3A9HzYYFskDH yi8kEC7aGkVyx5AuGwKfO28J70d/6o+i9RgtbyBV4A3IbpLKWO+X5e8X5UmPMvGbgHhs k/Vw== X-Gm-Message-State: ABUngvfxGFS7kONqRdntE67T93vAy8/J3JxI8Wv5bhZjpuP6+7l+9OrnXi8j0mnqQeb4lw== X-Received: by 10.194.178.200 with SMTP id da8mr12611615wjc.157.1478644620068; Tue, 08 Nov 2016 14:37:00 -0800 (PST) Received: from [192.168.2.21] (pD9E8FF48.dip0.t-ipconnect.de. [217.232.255.72]) by smtp.googlemail.com with ESMTPSA id vr9sm33592691wjc.35.2016.11.08.14.36.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 Nov 2016 14:36:59 -0800 (PST) From: Andreas Cadhalpun X-Google-Original-From: Andreas Cadhalpun To: FFmpeg development discussions and patches Message-ID: Date: Tue, 8 Nov 2016 23:36:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.4.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] icodec: correctly check avio_read return value 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" It can read less than the requested amount, in which case buf contains uninitialized data, causing problems like segmentation faults later on. Signed-off-by: Andreas Cadhalpun --- libavformat/icodec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavformat/icodec.c b/libavformat/icodec.c index 8019a35..aad1416 100644 --- a/libavformat/icodec.c +++ b/libavformat/icodec.c @@ -174,8 +174,8 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt) bytestream_put_le16(&buf, 0); bytestream_put_le32(&buf, 0); - if ((ret = avio_read(pb, buf, image->size)) < 0) - return ret; + if ((ret = avio_read(pb, buf, image->size)) != image->size) + return ret < 0 ? ret : AVERROR_INVALIDDATA; st->codecpar->bits_per_coded_sample = AV_RL16(buf + 14);