Re: libpq3 + ssl memory leak

Поиск
Список
Период
Сортировка
От Neil Conway
Тема Re: libpq3 + ssl memory leak
Дата
Msg-id 878ylhv762.fsf@mailbox.samurai.com
обсуждение исходный текст
Ответ на Re: libpq3 + ssl memory leak  (Neil Conway <neilc@samurai.com>)
Ответы Re: libpq3 + ssl memory leak  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: libpq3 + ssl memory leak  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
Okay, I've attached a patch that fixes the problem for me. The problem
turned out to be pretty simple: the PostgreSQL code (both backend and
frontend SSL support) was calling SSL_get_peer_certificate() without
properly free'ing its return value.

I haven't actually confirmed the backend memory leak, but it should be
readily reproduceable (the same OpenSSL API call is made and the
return value is never free'd).

Olaf, can you please test the attached patch? (Against CVS HEAD, but
should apply easily enough to 7.4.0) At the very least you'll need to
rebuild libpq and ensure that the test app picks up the new .so, but
testing the backend with the patch applied would also be helpful.

This fix needs to be in 7.4.1, so if anyone wants to review this
patch, that would be great.

-Neil

P.S. I added an assertion in the backend code to help catch any other
memory leaks in this area. I didn't add an equivalent one to the
frontend code, because libpq doesn't seem to be setup for
assertions. When this is applied to 7.4.1, we probably shouldn't
include the assertion at the risk of suffering backend crashes.


Вложения

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: failed to lookup type 0
Следующее
От: "cnliou"
Дата:
Сообщение: Re: RI within PLPGSQL