Skip site navigation (1) Skip section navigation (2)

Re: BUG #2260: PGCrypto Memory Problem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: Daniel Blaisdell <lunk(dot)djedi(at)gmail(dot)com>, pgsql-bugs(at)postgresql(dot)org, Marko Kreen <marko(at)l-t(dot)ee>
Subject: Re: BUG #2260: PGCrypto Memory Problem
Date: 2006-02-15 20:02:45
Message-ID: 19064.1140033765@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugs
Michael Fuhr <mike(at)fuhr(dot)org> writes:
> My non-OpenSSL build shows no memory leak, so the leak and OpenSSL
> seem to be correlated.  I'd be more inclined to suspect a bug in
> pgcrypto's OpenSSL-specific code than in OpenSSL itself.  Will keep
> digging.

The problem appears to be here:

static void
digest_finish(PX_MD * h, uint8 *dst)
{
    EVP_MD_CTX *ctx = (EVP_MD_CTX *) h->p.ptr;
    const EVP_MD *md = EVP_MD_CTX_md(ctx);

    EVP_DigestFinal(ctx, dst, NULL);

    /*
     * Some builds of 0.9.7x clear all of ctx in EVP_DigestFinal. Fix it by
     * reinitializing ctx.
     */
    EVP_DigestInit(ctx, md);
}

It looks like this results in a leak of the entire OpenSSL context for
each call to pg_crypt.  Marko, I trust you've got a better solution for
this ...

			regards, tom lane

In response to

Responses

pgsql-bugs by date

Next:From: Stephen FrostDate: 2006-02-15 20:05:26
Subject: Re: BUG #2246: Only call pg_fe_getauthname if none given
Previous:From: Michael FuhrDate: 2006-02-15 19:41:23
Subject: Re: BUG #2260: PGCrypto Memory Problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group