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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 2B11EC04A95 for ; Sun, 25 Sep 2022 15:03:43 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8631184B79; Sun, 25 Sep 2022 17:03:24 +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="ZAjWAPSi"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9E4B584B06; Sun, 25 Sep 2022 17:03:17 +0200 (CEST) Received: from mail-io1-xd32.google.com (mail-io1-xd32.google.com [IPv6:2607:f8b0:4864:20::d32]) (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 E97EA848C2 for ; Sun, 25 Sep 2022 17:03:14 +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-io1-xd32.google.com with SMTP id h194so3430028iof.4 for ; Sun, 25 Sep 2022 08:03:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=ZO+eAGwbxcXAlD9VKVLF5lYNvBk68zdu5bmVox7XhDI=; b=ZAjWAPSiHdMo6K6DYcmFcbefRZ3BnpzcIs3JbGpTMEfb5bYuS96Gx0lsBCKKbcZB2s A4wP/vt9G0YCr1ZczyL97CfXF+Zh/VVzuQdKHX/wnxcdx0agoENb3wngoAtUzPakOwQt 7VQOEcGQl07WlY2gkP9V84+NdXhiNeNSs0pgE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=ZO+eAGwbxcXAlD9VKVLF5lYNvBk68zdu5bmVox7XhDI=; b=MGtzfP2kWppZwZw/9jkP3QdO3hlf2f8yr9AzccmygpYWoZHnp0dskGc9Bh6FCu6L4O nvlBT7BSTeETchTNMjmKjjzzcuvl7/XadZL1bNY64HWKtw6pVxtwNA1jzFJiBikwpihF nLKHcKgTC3bUDIMLXK3WiDp4IH3D47dx7Q6Rg6qZ3S9c6kY6ndSp9x3f53TKpJ2L6Z3o w1JAwxkyBsA/btk0K0DBm8Az1hmLfcxtq9dNUKPUSqcHzxpX54jA7lSX+CFR96gLIMer Vi7rwsTT8y9Y6V+5RfwINRojd9QCgU+958a/kG1d0w7Qf1gLz6oy+kh4rM8e6gTvysfj 41+g== X-Gm-Message-State: ACrzQf0pxYDAS9Py5sRlaJ7SGeFpFx3Hdeej0WjutRyBbzWwJinapvgI z4ZhUN7MyfMCzHJHCkAuvRhrzzFQXHB8Pg== X-Google-Smtp-Source: AMsMyM4stGgR5j52r9DdkDCrYLhhcvHRlLYpq+ftWX9imJ5xaopZxJRrvwtAi/ia4UP7gBl/8I3RlA== X-Received: by 2002:a05:6638:4710:b0:35a:6372:3df0 with SMTP id cs16-20020a056638471000b0035a63723df0mr9315014jab.277.1664118193200; Sun, 25 Sep 2022 08:03:13 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id u19-20020a926013000000b002f19d9838c6sm5360578ilb.25.2022.09.25.08.03.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Sep 2022 08:03:12 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , Simon Glass , Alexandru Gagniuc , Heinrich Schuchardt , Jamin Lin , Philippe Reynes , SESA644425 Subject: [PATCH 04/45] rsa: Avoid warning in padding_pss_verify() Date: Sun, 25 Sep 2022 09:02:07 -0600 Message-Id: <20220925150248.2524421-5-sjg@chromium.org> X-Mailer: git-send-email 2.37.3.998.g577e59143f-goog In-Reply-To: <20220925150248.2524421-1-sjg@chromium.org> References: <20220925150248.2524421-1-sjg@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.6 at phobos.denx.de X-Virus-Status: Clean With gcc 12 we ge the following warning: In file included from tools/lib/rsa/rsa-verify.c:1: lib/rsa/rsa-verify.c:275:11: warning: ‘*db’ may be used uninitialized 275 | db[0] &= 0xff >> leftmost_bits; Check the value of db_len to ensure this cannot happen. Signed-off-by: Simon Glass --- lib/rsa/rsa-verify.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c index 1d95cfbdee0..81c39251e59 100644 --- a/lib/rsa/rsa-verify.c +++ b/lib/rsa/rsa-verify.c @@ -234,6 +234,11 @@ int padding_pss_verify(struct image_sign_info *info, uint8_t leftmost_mask; struct checksum_algo *checksum = info->checksum; + if (db_len <= 0) { + ret = -EINVAL; + goto out; + } + /* first, allocate everything */ db_mask = malloc(db_len); db = malloc(db_len); -- 2.37.3.998.g577e59143f-goog