Re: Fix for bug in ldapServiceLookup in libpq - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Fix for bug in ldapServiceLookup in libpq
Date
Msg-id 28650.1305129646@sss.pgh.pa.us
Whole thread Raw
In response to Fix for bug in ldapServiceLookup in libpq  ("Albe Laurenz" <laurenz.albe@wien.gv.at>)
List pgsql-hackers
"Albe Laurenz" <laurenz.albe@wien.gv.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


pgsql-hackers by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: the big picture for index-only scans
Next
From: Alvaro Herrera
Date:
Subject: Re: VARIANT / ANYTYPE datatype