From patchwork Thu Jun 1 17:10:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 100962 Delivered-To: patch@linaro.org Received: by 10.182.202.35 with SMTP id kf3csp861153obc; Thu, 1 Jun 2017 10:21:14 -0700 (PDT) X-Received: by 10.200.36.162 with SMTP id s31mr3480580qts.224.1496337674026; Thu, 01 Jun 2017 10:21:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496337674; cv=none; d=google.com; s=arc-20160816; b=nMJVQKUOZLYC1XA+PNrOJKWXGggVyOi/mvKJtuPMP7blRxubTFQ9G7JrdXyogxgw5S iz5DhV3e0mdqNIEGnZtUs8maBHmWkVTgJk7huXVhD38dfulT26KLBNZBkCP6QizLEqji uLCm0RLKjQnbymyCbuhGOoI4lEZCdG22hZLIb88SXEL72Ak1bKocAgXW9g/oGvCCM9z/ HJlJxW1MJvlJotJ7CNIEUc9X+lymdUmOVjeeGMIGQdX/PibIaCcn8kuOQkKoP+5hx0sV oJaaIOfw5DmeY/DRUidIIHjbLO3VopjNKlcZvhdTKIUkRiLcfHgkYbhI6jRiJylca8Yg zcvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=8zAyDdOR6dqaRkLTaaTImB1wtcyGXzElc1oGtEawhbw=; b=Fi+IpQD+qwP76QST5ra5TsuTcMneMIF9DNehI7x0xPXpcUrmw6zec/gxo+1IcvR3Rm tc4y3zaF8gLWjBCxhotahiFk3t9jrGxNn3vzr4JKJxUJS8l+/2u45fBs/N5/HLOGRVH3 mc+N/DxLw3HoBgKjh8lwRYqS5vrSM0iG16w+iNGZmxUXZ2vxxXjaTZTk2yXgoowj8zmk tzm6aBObGajDwULkEDGQbQDWuaA9YhN/9gxGjRqHm5FjDnsaTvqrsuuLvOeD/3o0SgdG 44QCtD5dpV03NT+L4GnFp+b5VzRe2c+Xw24rv7OMA9pZd0PvhVCyk2yTp7zD/bdZieK0 AZeQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m12si14490415qki.192.2017.06.01.10.21.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 01 Jun 2017 10:21:14 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45843 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGTmZ-0001wT-F3 for patch@linaro.org; Thu, 01 Jun 2017 13:21:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dGTcZ-00017F-B8 for qemu-devel@nongnu.org; Thu, 01 Jun 2017 13:10:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dGTcY-0006Bx-0V for qemu-devel@nongnu.org; Thu, 01 Jun 2017 13:10:51 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37147) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dGTcX-0006AO-Oh for qemu-devel@nongnu.org; Thu, 01 Jun 2017 13:10:49 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1dGTcL-0007NZ-NO for qemu-devel@nongnu.org; Thu, 01 Jun 2017 18:10:37 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 1 Jun 2017 18:10:10 +0100 Message-Id: <1496337035-30213-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496337035-30213-1-git-send-email-peter.maydell@linaro.org> References: <1496337035-30213-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 02/27] load_uboot_image: don't assume a full header read X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Andrew Jones Don't allow load_uboot_image() to proceed when less bytes than header-size was read. Signed-off-by: Andrew Jones Message-id: 20170524091315.20284-1-drjones@redhat.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- hw/core/loader.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/hw/core/loader.c b/hw/core/loader.c index bf17b42..f72930c 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -611,8 +611,9 @@ static int load_uboot_image(const char *filename, hwaddr *ep, hwaddr *loadaddr, return -1; size = read(fd, hdr, sizeof(uboot_image_header_t)); - if (size < 0) + if (size < sizeof(uboot_image_header_t)) { goto out; + } bswap_uboot_header(hdr);