]> granicus.if.org Git - postgresql/commit
Avoid possibly accessing off the end of memory in SJIS2004 conversion.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 6 Sep 2011 18:50:28 +0000 (14:50 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 6 Sep 2011 18:50:56 +0000 (14:50 -0400)
commitd5e429b128b0e222f9458a7880427a60da065fa3
treeb347d67a4b50ee153df239979be78b50fbd35f98
parentad1e8274ebd8cff2a9fb44c6a941110a35989375
Avoid possibly accessing off the end of memory in SJIS2004 conversion.

The code in shift_jis_20042euc_jis_2004() would fetch two bytes even when
only one remained in the string.  Since conversion functions aren't
supposed to assume null-terminated input, this poses a small risk of
fetching past the end of memory and incurring SIGSEGV.  No such crash has
been identified in the field, but we've certainly seen the equivalent
happen in other code paths, so patch this one all the way back.

Report and patch by Noah Misch.
src/backend/utils/mb/conversion_procs/euc2004_sjis2004/euc2004_sjis2004.c