postgresql/src/backend
Tom Lane 0887fa1117 Get pg_utf_mblen(), pg_utf2wchar_with_len(), and utf2ucs() all on the same
page about the maximum UTF8 sequence length we support (4 bytes since 8.1,
3 before that).  pg_utf2wchar_with_len never got updated to support 4-byte
characters at all, and in any case had a buffer-overrun risk in that it
could produce multiple pg_wchars from what mblen claims to be just one UTF8
character.  The only reason we don't have a major security hole is that most
callers allocate worst-case output buffers; the sole exception in released
versions appears to be pre-8.2 iwchareq() (ie, ILIKE), which can be crashed
due to zeroing out its return address --- but AFAICS that can't be exploited
for anything more than a crash, due to inability to control what gets written
there.  Per report from James Russell and Michael Fuhr.

Pre-8.1 the risk is much less, but I still think pg_utf2wchar_with_len's
behavior given an incomplete final character risks buffer overrun, so
back-patch that logic change anyway.

This patch also makes sure that UTF8 sequences exceeding the supported
length (whichever it is) are consistently treated as error cases, rather
than being treated like a valid shorter sequence in some places.
2007-01-24 17:12:17 +00:00
..
access Refactor the index AM API slightly: move currentItemData and 2007-01-20 18:43:35 +00:00
bootstrap Add COST and ROWS options to CREATE/ALTER FUNCTION, plus underlying pg_proc 2007-01-22 01:35:23 +00:00
catalog Add CREATE/ALTER/DROP OPERATOR FAMILY commands, also COMMENT ON OPERATOR 2007-01-23 05:07:18 +00:00
commands Add CREATE/ALTER/DROP OPERATOR FAMILY commands, also COMMENT ON OPERATOR 2007-01-23 05:07:18 +00:00
executor Relax an Assert() that has been found to be too strict in some situations 2007-01-24 01:25:47 +00:00
lib Remove remains of old depend target. 2007-01-20 17:16:17 +00:00
libpq Remove remains of old depend target. 2007-01-20 17:16:17 +00:00
main Remove remains of old depend target. 2007-01-20 17:16:17 +00:00
nodes Add CREATE/ALTER/DROP OPERATOR FAMILY commands, also COMMENT ON OPERATOR 2007-01-23 05:07:18 +00:00
optimizer Put back planner's ability to cache the results of mergejoinscansel(), 2007-01-22 20:00:40 +00:00
parser Add CREATE/ALTER/DROP OPERATOR FAMILY commands, also COMMENT ON OPERATOR 2007-01-23 05:07:18 +00:00
po Translation updates 2006-12-02 01:16:16 +00:00
port Remove remains of old depend target. 2007-01-20 17:16:17 +00:00
postmaster Back out use of FormatMessage(), does error values, not exception 2007-01-23 03:28:49 +00:00
regex Re-run pgindent, fixing a problem where comment lines after a blank 2005-11-22 18:17:34 +00:00
rewrite Remove remains of old depend target. 2007-01-20 17:16:17 +00:00
storage Remove remains of old depend target. 2007-01-20 17:16:17 +00:00
tcop Add CREATE/ALTER/DROP OPERATOR FAMILY commands, also COMMENT ON OPERATOR 2007-01-23 05:07:18 +00:00
utils Get pg_utf_mblen(), pg_utf2wchar_with_len(), and utf2ucs() all on the same 2007-01-24 17:12:17 +00:00
Makefile Remove remains of old depend target. 2007-01-20 17:16:17 +00:00
nls.mk Add _ to gettext triggers. Must have been forgotten here when it was introduced. 2005-10-04 11:14:03 +00:00