pgcrypto: fix memory leak in openssl.c

From: "Marko Kreen" <markokr(at)gmail(dot)com>
To: PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Cc: "Daniel Blaisdell" <lunk(dot)djedi(at)gmail(dot)com>, "Michael Fuhr" <mike(at)fuhr(dot)org>
Subject: pgcrypto: fix memory leak in openssl.c
Date: 2006-02-18 00:23:45
Message-ID: e51f66da0602171623j7a0d2c96l9b56196a4ffd6549@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

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+.

Reason for the messy code was that I tried to avoid creating
wrapper structure to transport algorithm info and tried to use
OpenSSL context for it. The fix is to create wrapper structure.

It also uses newer digest API to avoid memory allocations
on reset with newer OpenSSLs.

Attached are one patch for 7.3, 7.4, 8.0 branches and another
for 8.1 and HEAD.

Thanks to Daniel Blaisdell for reporting it.

--
marko

Attachment Content-Type Size
fix.73.74.80.diff text/x-patch 4.3 KB
fix.81.82.diff text/x-patch 5.8 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Milorad Poluga 2006-02-18 13:44:05 Interval subtracting
Previous Message Tom Lane 2006-02-17 06:15:22 Re: record statement boundaries