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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 B1757C4338F for ; Wed, 11 Aug 2021 14:18:30 +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 130E46105A for ; Wed, 11 Aug 2021 14:18:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 130E46105A Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E453E82DB7; Wed, 11 Aug 2021 16:18:27 +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=1628691508; bh=whvtC56IsH9xj4t2LtABODFJfwVMZOaNkNdSE3hry+E=; h=Subject:To:Cc:References:From:Date:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=kFEW0sVdU2eDMd1KitZ42dHewTYlQuLDteK5OpiVjOd6x51IFKZFkQ315Iq5RJBoA +Q3jRMrSnKtQnPZ5GdwQB1fDgbRi9mTZfWhOmdoVJmGOuMItMB4LB4A43sSuQCwhmR nYT3lcSkTWTJXLDxWgn6zMoDZ3P3NzR4xIPITk/FjTZFVPZZa/SRHkcRCQuoWhtqxK kswmecpidYjxNl0TGXy24hn/TUPHcPq7aKF9JUzMaWcEz5mImLZ543JLugvTp7sRlq HP3eC7/4iwlf427yMEkPrhuoIWwS+rcWrdyGLDd6k3bHCf5AzpDYkHQE2vCMzmnl9/ qTTTXUishKYLg== Received: by phobos.denx.de (Postfix, from userid 109) id 1E3FA82DAC; Wed, 11 Aug 2021 16:18:27 +0200 (CEST) Received: from mout-u-107.mailbox.org (mout-u-107.mailbox.org [IPv6:2001:67c:2050:1::465:107]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 38E8982DBC for ; Wed, 11 Aug 2021 16:18:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-u-107.mailbox.org (Postfix) with ESMTPS id 4GlBkR6zz8zQjYX; Wed, 11 Aug 2021 16:18:23 +0200 (CEST) Received: from smtp2.mailbox.org ([80.241.60.241]) by hefe.heinlein-support.de (hefe.heinlein-support.de [91.198.250.172]) (amavisd-new, port 10030) with ESMTP id aZ6j6_FLDh8m; Wed, 11 Aug 2021 16:18:21 +0200 (CEST) Subject: Re: [PATCH 1/4] tools: kwbimage: Verify supported image version To: =?UTF-8?Q?Pali_Roh=c3=a1r?= Cc: u-boot@lists.denx.de, =?UTF-8?Q?Marek_Beh=c3=ban?= References: <20210811081417.18010-1-pali@kernel.org> From: Stefan Roese Message-ID: Date: Wed, 11 Aug 2021 16:18:20 +0200 MIME-Version: 1.0 In-Reply-To: <20210811081417.18010-1-pali@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: de-DE Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 315C2183D X-Rspamd-UID: c5aa56 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 On 11.08.21 10:14, Pali Rohár wrote: > Only image versions 0 and 1 are supported. Verify it in > kwbimage_verify_header() function. > > Signed-off-by: Pali Rohár Reviewed-by: Stefan Roese Thanks, Stefan > --- > tools/kwbimage.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/tools/kwbimage.c b/tools/kwbimage.c > index 4bff02bb3fb5..80aae8a6b619 100644 > --- a/tools/kwbimage.c > +++ b/tools/kwbimage.c > @@ -1690,9 +1690,7 @@ static int kwbimage_verify_header(unsigned char *ptr, int image_size, > if (checksum != ext_hdr->checksum) > return -FDT_ERR_BADSTRUCTURE; > } > - } > - > - if (image_version((void *)ptr) == 1) { > + } else if (image_version((void *)ptr) == 1) { > struct main_hdr_v1 *mhdr = (struct main_hdr_v1 *)ptr; > uint32_t offset; > uint32_t size; > @@ -1762,6 +1760,8 @@ static int kwbimage_verify_header(unsigned char *ptr, int image_size, > if (image_checksum32(ptr + offset, size - 4) != > *(uint32_t *)(ptr + offset + size - 4)) > return -FDT_ERR_BADSTRUCTURE; > + } else { > + return -FDT_ERR_BADSTRUCTURE; > } > > return 0; > Viele Grüße, Stefan -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de