From patchwork Wed Feb 12 19:46:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Klotzbuecher X-Patchwork-Id: 1237060 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mkio.de Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mkio.de header.i=@mkio.de header.a=rsa-sha256 header.s=default header.b=YyQiz3Rh; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Hqsw5YH6z9s1x for ; Thu, 13 Feb 2020 06:47:16 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2150A811F5; Wed, 12 Feb 2020 20:47:14 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=mkio.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mkio.de header.i=@mkio.de header.b="YyQiz3Rh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D68C9811FA; Wed, 12 Feb 2020 20:47:12 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-relay.contabo.net (mail-relay.contabo.net [167.86.79.29]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8AF1E811F4 for ; Wed, 12 Feb 2020 20:47:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=mkio.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=mk@mkio.de Received: from pxmg2.contabo.net (localhost.localdomain [127.0.0.1]) by mail-relay.contabo.net (Proxmox) with ESMTP id 4335210132D for ; Wed, 12 Feb 2020 20:47:09 +0100 (CET) Received: from m2731.contabo.net (m2731.contabo.net [193.34.145.203]) by mail-relay.contabo.net (Proxmox) with ESMTPS id 65D19101350 for ; Wed, 12 Feb 2020 20:46:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mkio.de; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=r1Sys8rgdI3CMwuvB71DZzyjxSU6vgWI3FB4hUTtUBs=; b=YyQiz3RhKnp1P62np7P9phSESp GjXSInQBKQHEcH/w2rNh3CpIdmAAOJuPApxm2iDmBW4Tx4qG3DpImQDG3arD2o6lqZX3sF5gehoEv FDGOGJeKc980BIVu/er8TZIlJRr6JChsc+gVK/jI/Q0hPof+/2JY4CvCVWAsUZ82QAaF/ui1Wrxl9 O/LycYg0ZAVhr5zhCeTUKFxvS4WUaBHGJ9EXy4CDeGWSYYFjzZFYvmTVV2uvPDY3md1djKQl4IImb U7fbSOZXtDdw6q5zUhE2mjrByoERgoMif22AkDMZc0CYX37VQvgLFH8tJPLPiX2gPYNuORNEH6Jaj mREtmObA==; Received: from [78.43.53.173] (port=60566 helo=e495.int.kistler.com) by m2731.contabo.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92) (envelope-from ) id 1j1xyC-00EMea-BE; Wed, 12 Feb 2020 20:46:50 +0100 From: Markus Klotzbuecher To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Heiko Schocher , Tom Rini , Simon Glass , Joe Hershberger , Masahiro Yamada Subject: [PATCH 1/2] moveconfig: replace unsafe eval with asteval Date: Wed, 12 Feb 2020 20:46:44 +0100 Message-Id: <20200212194645.1765445-2-mk@mkio.de> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200212194645.1765445-1-mk@mkio.de> References: <20200212194645.1765445-1-mk@mkio.de> MIME-Version: 1.0 X-OutGoing-Spam-Status: No, score=-2.9 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - m2731.contabo.net X-AntiAbuse: Original Domain - lists.denx.de X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - mkio.de X-Get-Message-Sender-Via: m2731.contabo.net: authenticated_id: mk@mkio.de X-Authenticated-Sender: m2731.contabo.net: mk@mkio.de X-Source: X-Source-Args: X-Source-Dir: X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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" X-Virus-Scanned: clamav-milter 0.102.1 at phobos.denx.de X-Virus-Status: Clean Commit b237d358b "moveconfig: expand simple expressions" added support for expanding expressions in configs, but used the unsafe python built-in "eval". This patch fixes this by replacing eval with the asteval module. Signed-off-by: Markus Klotzbuecher Cc: Heinrich Schuchardt Cc: Heiko Schocher Cc: Tom Rini Cc: Simon Glass Cc: Joe Hershberger Cc: Masahiro Yamada Reviewed-by: Heinrich Schuchardt --- tools/moveconfig.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/moveconfig.py b/tools/moveconfig.py index 36160a3977..df20ec66af 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -295,6 +295,7 @@ To see the complete list of supported options, run """ +import asteval import collections import copy import difflib @@ -808,10 +809,11 @@ def try_expand(line): return line try: + aeval = asteval.Interpreter( usersyms=SIZES, minimal=True ) cfg, val = re.split("=", line) val= val.strip('\"') if re.search("[*+-/]|<<|SZ_+|\(([^\)]+)\)", val): - newval = hex(eval(val, SIZES)) + newval = hex(aeval(val)) print("\tExpanded expression %s to %s" % (val, newval)) return cfg+'='+newval except: From patchwork Wed Feb 12 19:46:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Klotzbuecher X-Patchwork-Id: 1237061 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mkio.de Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mkio.de header.i=@mkio.de header.a=rsa-sha256 header.s=default header.b=kpJM+01q; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Hqt56sW7z9s1x for ; Thu, 13 Feb 2020 06:47:25 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A2E21811FF; Wed, 12 Feb 2020 20:47:17 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=mkio.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=mkio.de header.i=@mkio.de header.b="kpJM+01q"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 034DC811F8; Wed, 12 Feb 2020 20:47:14 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-relay.contabo.net (mail-relay.contabo.net [167.86.79.29]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 89BF3811F5 for ; Wed, 12 Feb 2020 20:47:11 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=mkio.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=mk@mkio.de Received: from pxmg2.contabo.net (localhost.localdomain [127.0.0.1]) by mail-relay.contabo.net (Proxmox) with ESMTP id 48A9C10132D for ; Wed, 12 Feb 2020 20:47:11 +0100 (CET) Received: from m2731.contabo.net (m2731.contabo.net [193.34.145.203]) by mail-relay.contabo.net (Proxmox) with ESMTPS id 81F7510143C for ; Wed, 12 Feb 2020 20:46:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mkio.de; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=jgntD6HAeQ1vM8chpQw2Coo2FwfTDRJGy93WNHo442E=; b=kpJM+01qLqe7qiNk+zfFA5RBxw xu756iv9Oimpduy/M+RvC1BKG3fDPijQkMckYVm4QIcaqJV10iTPCWiulcfkyNLSEtu7TATZaFuLR 6di/5AYpiL/ZguHJHmOZ1z5rwzDS+1UcXl3JxIkrUKzw8z/yududm9w39xouwyBxl8xnXyi2MSCf8 rLKiRZNntolU+cJfB5+vNcXYZlQqftiV8A38VzBK0zkN+jY0cO3iZ0dQIt5mfD8WnPKD74Qh0+Me+ QizQ+bF/eXs/sJxWeeLKCalf1XaVUKN7yIyhxRaifwhjXos0egZcYWMoZBDlDivhNrdiXZnn5ZFb3 pEpftSrw==; Received: from [78.43.53.173] (port=60566 helo=e495.int.kistler.com) by m2731.contabo.net with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92) (envelope-from ) id 1j1xyE-00EMea-Gb; Wed, 12 Feb 2020 20:46:52 +0100 From: Markus Klotzbuecher To: u-boot@lists.denx.de Cc: Simon Glass , Tom Rini , Masahiro Yamada Subject: [PATCH 2/2] moveconfig: convert ps.stderr to string Date: Wed, 12 Feb 2020 20:46:45 +0100 Message-Id: <20200212194645.1765445-3-mk@mkio.de> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200212194645.1765445-1-mk@mkio.de> References: <20200212194645.1765445-1-mk@mkio.de> MIME-Version: 1.0 X-OutGoing-Spam-Status: No, score=-2.9 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - m2731.contabo.net X-AntiAbuse: Original Domain - lists.denx.de X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - mkio.de X-Get-Message-Sender-Via: m2731.contabo.net: authenticated_id: mk@mkio.de X-Authenticated-Sender: m2731.contabo.net: mk@mkio.de X-Source: X-Source-Args: X-Source-Dir: X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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" X-Virus-Scanned: clamav-milter 0.102.1 at phobos.denx.de X-Virus-Status: Clean Printing the error message in verbose mode fails, since python3 doesn't implicitely convert bytes to strings. Signed-off-by: Markus Klotzbuecher Cc: Simon Glass Cc: Tom Rini Cc: Masahiro Yamada Reviewed-by: Simon Glass --- tools/moveconfig.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/moveconfig.py b/tools/moveconfig.py index df20ec66af..d8bf7fd071 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -1217,7 +1217,7 @@ class Slot: "Failed to process.\n") if self.options.verbose: self.log += color_text(self.options.color, COLOR_LIGHT_CYAN, - self.ps.stderr.read()) + self.ps.stderr.read().decode()) self.finish(False) def do_defconfig(self):