Re: freeing LDAPMessage in CheckLDAPAuth

2022-09-06 Thread Michael Paquier
On Mon, Sep 05, 2022 at 02:50:09AM -0700, Zhihong Yu wrote: > Here is patch v4. FWIW, I am fine with what you are basically doing with v4, so I'd like to apply that on HEAD on the basis of consistency with libpq. As Tom said, this authentication path will fail, but I'd like to think that this is

Re: freeing LDAPMessage in CheckLDAPAuth

2022-09-05 Thread Zhihong Yu
On Sun, Sep 4, 2022 at 10:37 PM Michael Paquier wrote: > On Sun, Sep 04, 2022 at 06:52:37AM -0700, Zhihong Yu wrote: > > Please take a look at patch v3. > > Fine as far as it goes. I would have put the initialization of > search_message closer to ldap_search_s() for consistency with libpq. > Tha

Re: freeing LDAPMessage in CheckLDAPAuth

2022-09-04 Thread Michael Paquier
On Sun, Sep 04, 2022 at 06:52:37AM -0700, Zhihong Yu wrote: > Please take a look at patch v3. Fine as far as it goes. I would have put the initialization of search_message closer to ldap_search_s() for consistency with libpq. That's what we do with ldap_search_st(). -- Michael signature.asc Des

Re: freeing LDAPMessage in CheckLDAPAuth

2022-09-04 Thread Zhihong Yu
On Sun, Sep 4, 2022 at 3:58 AM Zhihong Yu wrote: > > > On Sun, Sep 4, 2022 at 12:25 AM Michael Paquier > wrote: > >> On Sun, Sep 04, 2022 at 01:52:10AM -0400, Tom Lane wrote: >> > I can't get too excited about this. All of the error exit paths in >> > backend authentication code will lead immed

Re: freeing LDAPMessage in CheckLDAPAuth

2022-09-04 Thread Zhihong Yu
On Sun, Sep 4, 2022 at 12:25 AM Michael Paquier wrote: > On Sun, Sep 04, 2022 at 01:52:10AM -0400, Tom Lane wrote: > > I can't get too excited about this. All of the error exit paths in > > backend authentication code will lead immediately to process exit, so > > the possibility of some memory b

Re: freeing LDAPMessage in CheckLDAPAuth

2022-09-04 Thread Michael Paquier
On Sun, Sep 04, 2022 at 01:52:10AM -0400, Tom Lane wrote: > I can't get too excited about this. All of the error exit paths in > backend authentication code will lead immediately to process exit, so > the possibility of some memory being leaked really has no consequences > worth worrying about. I

Re: freeing LDAPMessage in CheckLDAPAuth

2022-09-03 Thread Tom Lane
Michael Paquier writes: > On Sat, Sep 03, 2022 at 05:00:30PM -0700, Zhihong Yu wrote: >> Please see the attached patch which frees the search_message in the above >> case. > Yep, nice catch, I am reading the same thing as you do. I can see > that we already do that after a failing ldap_search_s

Re: freeing LDAPMessage in CheckLDAPAuth

2022-09-03 Thread Michael Paquier
On Sat, Sep 03, 2022 at 05:00:30PM -0700, Zhihong Yu wrote: >Note that *res* parameter of *ldap*_*search*_*ext*_*s()* > and *ldap*_*search*_*s()* >should be freed with *ldap*_*msgfree()* regardless of return > value of these >functions. > > Please see the attached patc

freeing LDAPMessage in CheckLDAPAuth

2022-09-03 Thread Zhihong Yu
Hi, In CheckLDAPAuth(), around line 2606: if (r != LDAP_SUCCESS) { ereport(LOG, (errmsg("could not search LDAP for filter \"%s\" on server \"%s\": %s", It seems that the call to ldap_msgfree() is missing in the above case. According to https://www.o