Page MenuHome GnuPG

Resource leak in file "cipher/elgamal.c" in function "elg_generate_ext" at line 644
Closed, ResolvedPublic

Description

File: cipher/elgamal.c

Function: elg_generate_ext
Line of error: 644

Resource leak occurs as variable "xvalue" with assigned memory is not freed
before going out of scope , which causes memory leak.

Libgcrypt version 1.5.4 code:

if (xvalue)

    ec = generate_using_x (&sk, nbits, xvalue, retfactors);
  else
    {

-> xvalue after being used is not freed, which amounts to resource leak.

Recommended Code:

  if (xvalue)
    {
      ec = generate_using_x (&sk, nbits, xvalue, retfactors);
      gcry_mpi_release (xvalue);
    }
  else
    {

I am attaching a patch for the same.

Details

Version
1.5.4

Related Objects