Message ID | 20210724150341.243074-2-sjg@chromium.org |
---|---|
State | Accepted |
Commit | 031725f8cdf33e836d19f35d3fe82c5baa5a2976 |
Delegated to: | Tom Rini |
Headers | show
Return-Path: <u-boot-bounces@lists.denx.de> 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=<UNKNOWN>) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=LH93XgeI; 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 4GX8bt3NfMz9sX1 for <incoming@patchwork.ozlabs.org>; Sun, 25 Jul 2021 01:04:26 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D05C082F2F; Sat, 24 Jul 2021 17:04:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="LH93XgeI"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 94F7D82EF4; Sat, 24 Jul 2021 17:03:55 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 24D7A82E3F for <u-boot@lists.denx.de>; Sat, 24 Jul 2021 17:03:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oi1-x22a.google.com with SMTP id y18so5408024oiv.3 for <u-boot@lists.denx.de>; Sat, 24 Jul 2021 08:03:48 -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=vku1vzDNWOQ0YJdJLOEQTeegTb6IonOj6owmVfPBnuQ=; b=LH93XgeI7TDPVsft0+U7p5NrDKRxwZeeGDXbAIko4eWaaS54tr1KwPj+wEpfZqiykq +L2WZN7TcUoP20nns9QqRGh4kyIaZTBWFL6woQ8CM06gCcJLI7cBZ+/fnWLVVVElLg2/ BkN0Od0Gp5cbW4gVzKGpaaY9bJd2LzXvj/ZFI= 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=vku1vzDNWOQ0YJdJLOEQTeegTb6IonOj6owmVfPBnuQ=; b=PNL2IsvxRi0lyWyzFoGtBfn2q8AYcZ8SmMs8tGeGaUIa3xvelVn2cyiu6zvmJGxCkv v3097HOEfMIkeJk/U6QuQNTT6yYKuo+sY8EZ2CwIvuy8iJuX3tPxFlG0f6pvqx+fgBnC drxLT2ha2se0jqk0+R1jftDCdXCGaX2nLHOTs573vzQVZj7CiLC3aK7l24XiIf/kR7Kk O9Flu+avi+/iUNpNv2hRpRxH/rw8hCqnv+VKusaV8e3OIJlyZvHatpbTRQ5n29bE61ft LcC/+u9w5jhHrRzwYR7I8y7uAB8jgKYJi8oX/Bo3N2KxJMLg+Qa419pwD+k1qu/TsKQs 3ZxQ== X-Gm-Message-State: AOAM5337UJwLYBYLQJGlnfCY8T299hlsDcT9QrjMKA3JmKxY4hfB13ar +91/DjemzTCwVca4m2v1StGXjjAR4+MVvtuA X-Google-Smtp-Source: ABdhPJyMKQAgg+oKbyNlNoKoUdlGhNarnTibroeyA1k6HhfimIx/DAhPiFX87YnPrg/dRBNdSPEhww== X-Received: by 2002:a05:6808:10cf:: with SMTP id s15mr6570813ois.119.1627139026232; Sat, 24 Jul 2021 08:03:46 -0700 (PDT) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id w190sm6704082oif.17.2021.07.24.08.03.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Jul 2021 08:03:45 -0700 (PDT) From: Simon Glass <sjg@chromium.org> To: U-Boot Mailing List <u-boot@lists.denx.de> Cc: Tom Rini <trini@konsulko.com>, "Jonathan A . Kollasch" <jakllsch@kollasch.net>, Marek Vasut <marex@denx.de>, Heinrich Schuchardt <xypron.glpk@gmx.de>, =?utf-8?q?Marek_Beh=C3=BAn?= <marek.behun@nic.cz>, Eugeniu Rosca <erosca@de.adit-jv.com>, Roland Gaudig <roland.gaudig@weidmueller.com>, Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>, Sean Anderson <seanga2@gmail.com>, Simon Glass <sjg@chromium.org>, Joe Hershberger <joe.hershberger@ni.com> Subject: [PATCH v2 01/14] hash: Ensure verification hex pairs are terminated Date: Sat, 24 Jul 2021 09:03:28 -0600 Message-Id: <20210724150341.243074-2-sjg@chromium.org> X-Mailer: git-send-email 2.32.0.432.gabb21c7263-goog In-Reply-To: <20210724150341.243074-1-sjg@chromium.org> References: <20210724150341.243074-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion <u-boot.lists.denx.de> List-Unsubscribe: <https://lists.denx.de/options/u-boot>, <mailto:u-boot-request@lists.denx.de?subject=unsubscribe> List-Archive: <https://lists.denx.de/pipermail/u-boot/> List-Post: <mailto:u-boot@lists.denx.de> List-Help: <mailto:u-boot-request@lists.denx.de?subject=help> List-Subscribe: <https://lists.denx.de/listinfo/u-boot>, <mailto:u-boot-request@lists.denx.de?subject=subscribe> Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" <u-boot-bounces@lists.denx.de> X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean |
Series |
lib: Add support for a decimal 0t prefix for numbers
|
expand
|
On Sat, Jul 24, 2021 at 09:03:28AM -0600, Simon Glass wrote: > This function seems to assume that the chr[] variable contains zeros at > the start, which is not always true. Use strlcpy() to be safe. > > Signed-off-by: Simon Glass <sjg@chromium.org> Applied to u-boot/master, thanks!
diff --git a/common/hash.c b/common/hash.c index 90cf46bcba5..059d381e231 100644 --- a/common/hash.c +++ b/common/hash.c @@ -396,7 +396,7 @@ int hash_parse_string(const char *algo_name, const char *str, uint8_t *result) for (i = 0; i < algo->digest_size; i++) { char chr[3]; - strncpy(chr, &str[i * 2], 2); + strlcpy(chr, &str[i * 2], 3); result[i] = simple_strtoul(chr, NULL, 16); }
This function seems to assume that the chr[] variable contains zeros at the start, which is not always true. Use strlcpy() to be safe. Signed-off-by: Simon Glass <sjg@chromium.org> --- (no changes since v1) common/hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)