]> granicus.if.org Git - postgresql/commit
Fix inadequately-sized output buffer in contrib/unaccent.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 1 Jul 2014 15:22:53 +0000 (11:22 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 1 Jul 2014 15:22:53 +0000 (11:22 -0400)
commitc66256b9bd34a4af477eb3dc558ac8f46727f2f3
treefdc1f0d48ca596866c2c8a3dbadbaa74ea3201c2
parentf6d6b7b1e7eac2aa049bbb1e41c468fbbf5b7fef
Fix inadequately-sized output buffer in contrib/unaccent.

The output buffer size in unaccent_lexize() was calculated as input string
length times pg_database_encoding_max_length(), which effectively assumes
that replacement strings aren't more than one character.  While that was
all that we previously documented it to support, the code actually has
always allowed replacement strings of arbitrary length; so if you tried
to make use of longer strings, you were at risk of buffer overrun.  To fix,
use an expansible StringInfo buffer instead of trying to determine the
maximum space needed a-priori.

This would be a security issue if unaccent rules files could be installed
by unprivileged users; but fortunately they can't, so in the back branches
the problem can be labeled as improper configuration by a superuser.
Nonetheless, a memory stomp isn't a nice way of reacting to improper
configuration, so let's back-patch the fix.
contrib/unaccent/unaccent.c