mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-08 12:44:23 +01:00
mpi: Improve mpi_invm to detect bad input.
* mpi/mpi-inv.c (mpi_invm): Return 0 for bad input. -- Without this patch the function may enter an endless loop. This is a backport from libgcrypt. GnuPG-bug-id: 1713
This commit is contained in:
parent
b89f57fe5d
commit
cd53cdbc37
@ -165,6 +165,11 @@ mpi_invm( MPI x, MPI a, MPI n )
|
|||||||
int sign;
|
int sign;
|
||||||
int odd ;
|
int odd ;
|
||||||
|
|
||||||
|
if (!mpi_cmp_ui (a, 0))
|
||||||
|
return 0; /* Inverse does not exists. */
|
||||||
|
if (!mpi_cmp_ui (n, 1))
|
||||||
|
return 0; /* Inverse does not exists. */
|
||||||
|
|
||||||
u = mpi_copy(a);
|
u = mpi_copy(a);
|
||||||
v = mpi_copy(n);
|
v = mpi_copy(n);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user