Re: Fix for bug in ldapServiceLookup in libpq

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>
Cc: "pgsql-hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix for bug in ldapServiceLookup in libpq
Date: 2011-05-11 16:00:46
Message-ID: 28650.1305129646@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at> writes:
> I have found a small but annoying bug in libpq where
> connection parameters are resolved via LDAP.

> There is a write past the end of a malloc'ed string which causes
> memory corruption. The code and the bug are originally by me :^(

Hmm ... that's a bug all right, but why have the null-termination
inside the loop at all? Seems like it should look like

for (p = result, i = 0; values[i] != NULL; ++i)
{
strncpy(p, values[i]->bv_val, values[i]->bv_len);
p += values[i]->bv_len;
*(p++) = '\n';
}
*p = '\0';

> This should be backpatched to 8.2 where the code was introduced.

Yes, will do.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2011-05-11 16:02:53 Re: VARIANT / ANYTYPE datatype
Previous Message Kevin Grittner 2011-05-11 15:51:46 Re: the big picture for index-only scans