pgsql: Fix insufficiently-paranoid GB18030 encoding verifier.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix insufficiently-paranoid GB18030 encoding verifier.
Date: 2015-05-15 15:04:14
Message-ID: E1YtH9q-0006Fl-QY@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Heikki Linnakangas 2015-05-15 15:10:25 pgsql: Fix datatype confusion with the new lossy GiST distance function
Previous Message Stephen Frost 2015-05-15 14:47:21 Re: pgsql: Make repeated 'make installcheck' runs work