Re: Bug in bttext_abbrev_convert()

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Peter Geoghegan <pg(at)heroku(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Bug in bttext_abbrev_convert()
Date: 2015-06-30 03:54:29
Message-ID: CA+Tgmoaft76esKmCYzsPct_iEJuvVTTX8-oyWaHjPBQsDosR6Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jun 29, 2015 at 7:47 PM, Peter Geoghegan <pg(at)heroku(dot)com> wrote:
> Commits b181a919 and arguably c79b6413 added bugs to
> bttext_abbrev_convert() in the process of fixing some others. In the
> master branch, bttext_abbrev_convert() can leak memory when the C
> locale happens to be used and we must detoast, which is unacceptable
> for about the same reason that it's unacceptable for a standard B-Tree
> comparator routine. There could also be a use-after-free issue for
> large strings that are detoasted, because bttext_abbrev_convert()
> hashes memory which might already be freed (when hashing the
> authoritative value).
>
> Attached patch fixes these issues.
>
> As we all know, the state of automated testing is pretty lamentable.
> This is the kind of thing that we could catch more easily in the
> future if better infrastructure were in place. I caught this by
> eyeballing bttext_abbrev_convert() with slightly fresher eyes than the
> last time I looked.

Committed.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2015-06-30 04:02:05 Re: drop/truncate table sucks for large values of shared buffers
Previous Message Amit Kapila 2015-06-30 03:21:11 Re: Reduce ProcArrayLock contention