From patchwork Mon Jul 8 20:25:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1129333 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="c21I/MUG"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45jHQZ4mJxz9sNk for ; Tue, 9 Jul 2019 06:40:38 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 4E08BC21C29; Mon, 8 Jul 2019 20:36:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id D6668C21EA1; Mon, 8 Jul 2019 20:28:50 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 2EE3FC21E18; Mon, 8 Jul 2019 20:27:56 +0000 (UTC) Received: from mail-io1-f66.google.com (mail-io1-f66.google.com [209.85.166.66]) by lists.denx.de (Postfix) with ESMTPS id 8D74FC21E29 for ; Mon, 8 Jul 2019 20:27:52 +0000 (UTC) Received: by mail-io1-f66.google.com with SMTP id k8so38350153iot.1 for ; Mon, 08 Jul 2019 13:27:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f4TUsdFjJGMUACfufN03Gkc37gWWH7LV6tMUGhBbwJ8=; b=c21I/MUGQjGpyVXlKa1j3HaluGKycnooweXUXUfr4qjoGZ7UlGhsLTlG7PAFH6p08I VxvwknoJcYWRMURdVsO2XcuQzNcgecHGOoftqh7pr911yYu00iQ31ytJUyoUhlmGi3+f AGNUXmg/SVymMy15eYeUm9QbMmoD7OyBg5OTE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f4TUsdFjJGMUACfufN03Gkc37gWWH7LV6tMUGhBbwJ8=; b=coWXJO1uNVxpxLZnKxosLNRuqxsNtTJHRP6wkTYAcBw5L3LQmCGbjsNiEZHrbbG1+R dhzs27mndf91wFPdrqLhSpXWyYBbDGVFiFEdqQiCpuIq3tZXz7lVbpdfLIE1Hs2w0YkI n1TN+YFmw2DKvcRnC175yuRPeT1VGM6aEZjZ620b65BYSPFj/6An/LvnFqw9ji8wPG5q 77GjXEAjZ6peG4tWQI2kBge3AEzpLHdhyvnXtCz6/3iTW6SQuaPWDP4f39dA++xcUOk4 wOqTT/xohGeIxxvu9xBpXneOm8/++2mkN834MsSJ7KGaX3X1xV6qJaY7jvqukVU34aaX avLA== X-Gm-Message-State: APjAAAW1E0yqrLAZG5cB4F5VOb6v6ewlIpKs+ltDWFzugrV8wp2aP9cs 3xqW2oX9IW+dPAEs85ColFJLrxFr2F4= X-Google-Smtp-Source: APXvYqz4B5+dmeklPmUT8btB2xN0vi72Ha/xhOHsU3Lg2XM0faqNVZKKggmP39LNqlLFLJ/+483vBw== X-Received: by 2002:a5d:8a06:: with SMTP id w6mr3795255iod.267.1562617671457; Mon, 08 Jul 2019 13:27:51 -0700 (PDT) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id v13sm16692359ioq.13.2019.07.08.13.27.50 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 08 Jul 2019 13:27:51 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Date: Mon, 8 Jul 2019 14:25:42 -0600 Message-Id: <20190708202553.225715-21-sjg@chromium.org> X-Mailer: git-send-email 2.22.0.410.gd8fdbe21b5-goog In-Reply-To: <20190708202553.225715-1-sjg@chromium.org> References: <20190708202553.225715-1-sjg@chromium.org> MIME-Version: 1.0 Cc: Tom Rini Subject: [U-Boot] [PATCH v2 20/31] binman: Detect bad CBFS file types X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Detect when an unknown or unsupported file type is specified and report an error. Signed-off-by: Simon Glass Signed-off-by: Simon Glass --- Changes in v2: None tools/binman/etype/cbfs.py | 3 +++ tools/binman/ftest.py | 6 ++++++ tools/binman/test/126_cbfs_bad_type.dts | 17 +++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 tools/binman/test/126_cbfs_bad_type.dts diff --git a/tools/binman/etype/cbfs.py b/tools/binman/etype/cbfs.py index a46bb98a033..175ecae1584 100644 --- a/tools/binman/etype/cbfs.py +++ b/tools/binman/etype/cbfs.py @@ -190,6 +190,9 @@ class Entry_cbfs(Entry): elif entry._type == 'stage': cfile = cbfs.add_file_stage(entry._cbfs_name, data, entry._cbfs_offset) + else: + entry.Raise("Unknown cbfs-type '%s' (use 'raw', 'stage')" % + entry._type) if cfile: entry._cbfs_file = cfile entry.size = cfile.data_len diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 999d8884aca..21bea6c9d13 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -2185,6 +2185,12 @@ class TestFunctional(unittest.TestCase): 'cbfs/u-boot-dtb:image-pos': 0xb8, }, props) + def testCbfsBadType(self): + """Test an image header with a no specified location is detected""" + with self.assertRaises(ValueError) as e: + self._DoReadFile('126_cbfs_bad_type.dts') + self.assertIn("Unknown cbfs-type 'badtype'", str(e.exception)) + if __name__ == "__main__": unittest.main() diff --git a/tools/binman/test/126_cbfs_bad_type.dts b/tools/binman/test/126_cbfs_bad_type.dts new file mode 100644 index 00000000000..2cd6fc6d52d --- /dev/null +++ b/tools/binman/test/126_cbfs_bad_type.dts @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + cbfs { + size = <0x100>; + u-boot { + cbfs-type = "badtype"; + }; + }; + }; +};