Fix possible buffer overrun in contrib/pg_trgm.

Tom Lane <tgl@sss.pgh.pa.us>

Commit: f261ad241daa37e3e040e2a43727a3b5703eff87
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2014-01-13T18:07:23Z
Releases: 9.0.16
Fix possible buffer overrun in contrib/pg_trgm.

Allow for the possibility that folding a string to lower case makes it
longer (due to replacing a character with a longer multibyte character).
This doesn't change the number of trigrams that will be extracted, but
it does affect the required size of an intermediate buffer in
generate_trgm().  Per bug #8821 from Ufuk Kayserilioglu.

Also install some checks that the input string length is not so large
as to cause overflow in the calculations of palloc request sizes.

Back-patch to all supported versions.

Files

PathChange+/−
contrib/pg_trgm/trgm_op.c modified +21 −3