Re: pgcrypto: fix memory leak in openssl.c - Mailing list pgsql-patches

From Marko Kreen
Subject Re: pgcrypto: fix memory leak in openssl.c
Date
Msg-id e51f66da0602200506o2537e171n807d1077d55514ac@mail.gmail.com
Whole thread Raw
In response to pgcrypto: fix memory leak in openssl.c  ("Marko Kreen" <markokr@gmail.com>)
Responses Re: pgcrypto: fix memory leak in openssl.c  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
On 2/18/06, Marko Kreen <markokr@gmail.com> wrote:
> pgcrypto crypt()/md5 and hmac() leak memory when compiled against
> OpenSSL as openssl.c digest ->reset will do two DigestInit calls
> against a context.  This happened to work with OpenSSL 0.9.6
> but not with 0.9.7+.

Ugh, seems I read the old code slightly wrong.  The leak happens
also with regular digest(), although it will leak only 1 context
instance, not the 1000+ as the crypt-md5 does.  And on 8.1 there
is pgp_sym_encrypt that also does lots of resets on one context,
like crypt-md5.  In addition it does regular digest() in several
places.  So if compiled against OpenSSL, its leaking everywhere.

The positive side is that only 8.1 has openssl autoconfiguration,
older versions default to builtin algorithms that can be changed
only by editing Makefile, thus most packages are hopefully safe.

--
marko

pgsql-patches by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: [PATCH] WIP: Create shell-types explicitly
Next
From: Tom Lane
Date:
Subject: Re: pgcrypto: fix memory leak in openssl.c