[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200930130123.8064-1-colin.king@canonical.com>
Date: Wed, 30 Sep 2020 14:01:23 +0100
From: Colin King <colin.king@...onical.com>
To: Andrew Morton <akpm@...ux-foundation.org>,
Johannes Weiner <hannes@...xchg.org>,
Herbert Xu <herbert@...dor.apana.org.au>,
Tianjia Zhang <tianjia.zhang@...ux.alibaba.com>,
Waiman Long <longman@...hat.com>
Cc: kernel-janitors@...r.kernel.org, linux-crypto@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH][next][resend] lib/mpi: fix off-by-one check on index "no"
From: Colin Ian King <colin.king@...onical.com>
There is an off-by-one range check on the upper limit of
index "no". Fix this by changing the > comparison to >=
Addresses-Coverity: ("Out-of-bounds read")
Fixes: a8ea8bdd9df9 ("lib/mpi: Extend the MPI library")
Signed-off-by: Colin Ian King <colin.king@...onical.com>
---
resend to Cc linux-crypto
---
lib/mpi/mpiutil.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/mpi/mpiutil.c b/lib/mpi/mpiutil.c
index 3c63710c20c6..632d0a4bf93f 100644
--- a/lib/mpi/mpiutil.c
+++ b/lib/mpi/mpiutil.c
@@ -69,7 +69,7 @@ postcore_initcall(mpi_init);
*/
MPI mpi_const(enum gcry_mpi_constants no)
{
- if ((int)no < 0 || no > MPI_NUMBER_OF_CONSTANTS)
+ if ((int)no < 0 || no >= MPI_NUMBER_OF_CONSTANTS)
pr_err("MPI: invalid mpi_const selector %d\n", no);
if (!constants[no])
pr_err("MPI: MPI subsystem not initialized\n");
--
2.27.0
Powered by blists - more mailing lists