pgsql: Fix insufficiently-paranoid GB18030 encoding verifier. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Fix insufficiently-paranoid GB18030 encoding verifier.
Date
Msg-id E1YtH9q-0006Fl-QY@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Fix insufficiently-paranoid GB18030 encoding verifier.

The previous coding effectively only verified that the second byte of a
multibyte character was in the expected range; moreover, it wasn't careful
to make sure that the second byte even exists in the buffer before touching
it.  The latter seems unlikely to cause any real problems in the field
(in particular, it could never be a problem with null-terminated input),
but it's still a bug.

Since GB18030 is not a supported backend encoding, the only thing we'd
really be doing with GB18030 text is converting it to UTF8 in LocalToUtf,
which would fail anyway on any invalid character for lack of a match in
its lookup table.  So the only user-visible consequence of this change
should be that you'll get "invalid byte sequence for encoding" rather than
"character has no equivalent" for malformed GB18030 input.  However,
impending changes to the GB18030 conversion code will require these tighter
up-front checks to avoid producing bogus results.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/a868931fecdf93f3ceb1c9431bb93757b706269d

Modified Files
--------------
src/backend/utils/mb/wchar.c |   52 +++++++++++++++++++++++-------------------
1 file changed, 29 insertions(+), 23 deletions(-)


pgsql-committers by date:

Previous
From: Stephen Frost
Date:
Subject: Re: pgsql: Make repeated 'make installcheck' runs work
Next
From: Heikki Linnakangas
Date:
Subject: pgsql: Fix datatype confusion with the new lossy GiST distance function