From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1BDB9C11F66 for ; Tue, 29 Jun 2021 10:41:06 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D9A1361DC7 for ; Tue, 29 Jun 2021 10:41:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D9A1361DC7 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BCE5B8313C; Tue, 29 Jun 2021 12:41:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1624963262; bh=L9j0Q5JnDdkTfMnSU2vptHvLm4c3iZsoolY3XwuSAog=; h=To:cc:From:Subject:In-reply-to:References:Date:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=yyN9rGxyF+ZW5grHbjmCH48lTCdifS3SABMtSbDto6hMy82/HJaoe2h0fnxJT7CUw FX3UBwi3tYAksmxNbuWLOEVxQuKZ+Xz6PJ7SNoUsAqN9kqLsxNW0kNMrTKvS5p8UgF Msa/6PQ1UbWfV0/m6H+u5CLt6K2rXDQs8ABCG4XxN3YoiiYpEwY3kMPndp5YvT/V4J A5cEZoyojdmV2G6ALe2DMec+2miGtgSG/4wZqvzuJIBTLPwEHyDgUBnGlDZjVs17l3 XaeTu4Ge7+73EoTpGWwI03ckgpHXWzWuP9ayl1E3TpM+MxjrZpwfbRisAA5fzearQg otS2MjCC2Xq8Q== Received: from janitor.denx.de (unknown [62.91.23.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: noc@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 97AD182E54 for ; Tue, 29 Jun 2021 12:40:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1624963259; bh=L9j0Q5JnDdkTfMnSU2vptHvLm4c3iZsoolY3XwuSAog=; h=To:cc:From:Subject:In-reply-to:References:Date:From; b=V+YKfvxppW4q3r2pZm5ILEcSqrYwGl3IjUgEn16ChaLcDn+YhruIk+wL13/WhFFGu 3HGXGpuWx/Vbjed6moYpXRXjnT4PJ4zf8REDSoB41kGlfNXflHsqnNZia7WMkCnnZn VH0oFz/CD3t3RcCvJoDYQ1iydxLkMMwsIKoblWE3laEvKgMqgFFS5rgqe6ubXulLeW 7UaM+HLOyVokje9jf6uM4N/q8YlL7tN+5BGqj1ebRhDYoSMxA7bD0bE2F7vmJ4Mh9r onYrn4JLqMBRJsEhW0j3MVK0+tegsJ1wvoDFFMP5MuPsVqeaTdMoKYyOTs4xjD7y+L Ydsg0kyINDftQ== Received: by janitor.denx.de (Postfix, from userid 108) id 4F2E9A027E; Tue, 29 Jun 2021 12:40:59 +0200 (CEST) Received: from gemini.denx.de (gemini.denx.de [10.4.0.2]) by janitor.denx.de (Postfix) with ESMTPS id C6D6AA005E; Tue, 29 Jun 2021 12:40:51 +0200 (CEST) Received: from gemini.denx.de (localhost [IPv6:::1]) by gemini.denx.de (Postfix) with ESMTP id 6DE051E1DD2; Tue, 29 Jun 2021 12:40:51 +0200 (CEST) To: "Roland Gaudig (OSS)" cc: u-boot@lists.denx.de, Simon Glass , Roland Gaudig , Alex Nemirovsky , Bin Meng , Heinrich Schuchardt , =?UTF-8?Q?Marek_Beh=c3=ban?= , Patrick Delaunay , Rayagonda Kokatanur , Robert Marko , Sean Anderson , Stefan Bosch , Weijie Gao From: Wolfgang Denk Subject: Re: [PATCH 0/3] cmd: setexpr: add fmt format string operation MIME-Version: 1.0 Content-type: text/plain; charset=UTF-8 Content-transfer-encoding: 8bit In-reply-to: References: <20210628151750.572837-1-roland.gaudig-oss@weidmueller.com> <83741.1624955845@gemini.denx.de> Comments: In-reply-to "Roland Gaudig (OSS)" message dated "Tue, 29 Jun 2021 09:41:25 -0000." Date: Tue, 29 Jun 2021 12:40:51 +0200 Message-ID: <89618.1624963251@gemini.denx.de> X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.103.2 at phobos.denx.de X-Virus-Status: Clean Dear Roland, In message you wrote: > > > These are two pretty unfortunate restrictions. I guess it should > > not be too hard to avoid both of these. Can you please give it a > > try? > > I think it is possible to allow more than one format parameter or more > types. But it would make checking much more difficult. Maybe we need _less_ checking, not more - and maybe the needed checking is already done in the *printf() code? > I think just passing the format string directly to sprintf should be > avoided because it is unsafe. For example > > => setexpr foo fmt %s 0xffffffff > > would surely lead to access on memory location outside the variable > where 0xffffffff is stored. Only if you make the wrong assumptions. I would expect this to result in foo=0xffffffff in the same way as the bash builting gives $ printf '%s\n' 0xffffffff 0xffffffff > > => setexpr foo fmt "%0x08x-%s-%d-%s" $a $b $c $d > > I think the only way to support such expressions in a save way would > be implementing an own format string parser for setexpr with Maybe it makes sense to have a look at the bash code? Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de How many seconds are there in a year? If I tell you there are 3.155 x 10^7, you won't even try to remember it. On the other hand, who could forget that, to within half a percent, pi seconds is a nanocentury. -- Tom Duff, Bell Labs