]> granicus.if.org Git - postgresql/commit
Fix not-terribly-safe coding in NIImportOOAffixes() and NIImportAffixes().
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 7 Mar 2016 00:21:03 +0000 (19:21 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 7 Mar 2016 00:21:03 +0000 (19:21 -0500)
commitfe747b741d71a921c1a29f06902c73a263af7c65
tree7d45e0a273b2db6515126be992f4d5dcf0fa3f62
parent58c1af4fd0952a9ac45b06824dcaee6f5fbdd737
Fix not-terribly-safe coding in NIImportOOAffixes() and NIImportAffixes().

There were two places in spell.c that supposed that they could search
for a location in a string produced by lowerstr() and then transpose
the offset into the original string.  But this fails completely if
lowerstr() transforms any characters into characters of different byte
length, as can happen in Turkish UTF8 for instance.

We'd added some comments about this coding in commit 51e78ab4ff328296,
but failed to realize that it was not merely confusing but wrong.

Coverity complained about this code years ago, but in such an opaque
fashion that nobody understood what it was on about.  I'm not entirely
sure that this issue *is* what it's on about, actually, but perhaps
this patch will shut it up -- and in any case the problem is clear.

Back-patch to all supported branches.
src/backend/tsearch/spell.c