From 6a8c7d67cf548d8d9adde703d47e5daa2e132ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= <nisse@lysator.liu.se> Date: Thu, 11 Mar 1999 17:01:09 +0100 Subject: [PATCH] * modules/Gmp/next_prime.c (mpz_next_prime): Fixed off-by-one overflow. Rev: src/modules/Gmp/next_prime.c:1.9 --- src/modules/Gmp/next_prime.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/Gmp/next_prime.c b/src/modules/Gmp/next_prime.c index 5331388829..7e126f2e66 100644 --- a/src/modules/Gmp/next_prime.c +++ b/src/modules/Gmp/next_prime.c @@ -1,4 +1,4 @@ -/* $Id: next_prime.c,v 1.8 1998/07/11 16:24:00 grubba Exp $ +/* $Id: next_prime.c,v 1.9 1999/03/11 16:01:09 nisse Exp $ * * Prime number test using trial division for small primes and then * Miller-Rabin, as suggested in Schneier's Applied Cryptography. @@ -9,7 +9,7 @@ #include "global.h" -RCSID("$Id: next_prime.c,v 1.8 1998/07/11 16:24:00 grubba Exp $"); +RCSID("$Id: next_prime.c,v 1.9 1999/03/11 16:01:09 nisse Exp $"); #include "gmp_machine.h" @@ -177,7 +177,7 @@ mpz_next_prime(mpz_t p, mpz_t n, int count, int prime_limit) if (prime_limit) { /* Compute residues modulo small odd primes */ - moduli = (unsigned long*) alloca((prime_limit -1) * sizeof(*moduli)); + moduli = (unsigned long*) alloca(prime_limit * sizeof(*moduli)); for (i = 0; i < prime_limit; i++) moduli[i] = mpz_fdiv_ui(p, primes[i + 1]); } -- GitLab