postgresql/src
Tom Lane bf4a9562e8 Make ts_locale.c's character-type functions cope with UTF-16.
On Windows, in UTF8 database encoding, what char2wchar() produces is
UTF16 not UTF32, ie, characters above U+FFFF will be represented by
surrogate pairs.  t_isdigit() and siblings did not account for this
and failed to provide a large enough result buffer.  That in turn
led to bogus "invalid multibyte character for locale" errors, because
contrary to what you might think from char2wchar()'s documentation,
its Windows code path doesn't cope sanely with buffer overflow.

The solution for t_isdigit() and siblings is pretty clear: provide
a 3-wchar_t result buffer not 2.

char2wchar() also needs some work to provide more consistent, and more
accurately documented, buffer overrun behavior.  But that's a bigger job
and it doesn't actually have any immediate payoff, so leave it for later.

Per bug #15476 from Kenji Uno, who deserves credit for identifying the
cause of the problem.  Back-patch to all active branches.

Discussion: https://postgr.es/m/15476-4314f480acf0f114@postgresql.org
2018-11-03 13:56:10 -04:00
..
backend Make ts_locale.c's character-type functions cope with UTF-16. 2018-11-03 13:56:10 -04:00
bin pg_restore: Augment documentation for -N option 2018-10-29 11:32:27 +01:00
common Revert "Allow concurrent-safe open() and fopen() in frontend code for Windows" 2018-09-18 17:28:27 -04:00
fe_utils Fix lexing of standard multi-character operators in edge cases. 2018-08-23 21:43:51 +01:00
include Fix interaction of CASE and ArrayCoerceExpr. 2018-10-30 15:26:11 -04:00
interfaces Client-side fixes for delayed NOTIFY receipt. 2018-10-19 22:22:57 -04:00
makefiles Refactor installation of extension headers. 2018-09-07 14:30:15 +01:00
pl Still further rethinking of build changes for macOS Mojave. 2018-10-18 14:55:23 -04:00
port Set snprintf.c's maximum number of NL arguments to be 31. 2018-10-02 12:41:28 -04:00
template Yet further rethinking of build changes for macOS Mojave. 2018-11-02 18:54:00 -04:00
test Fix tablespace handling for partitioned indexes 2018-11-03 13:25:29 -03:00
timezone Sync our copy of the timezone library with IANA release tzcode2018g. 2018-10-31 09:48:04 -04:00
tools Fix perl searchpath for modern perl for MSVC tools 2018-10-28 12:23:19 -04:00
tutorial Update copyright for 2018 2018-01-02 23:30:12 -05:00
.gitignore
DEVELOPERS
Makefile Fix partial-build problems introduced by having more generated headers. 2018-04-09 16:42:10 -04:00
Makefile.global.in Yet further rethinking of build changes for macOS Mojave. 2018-11-02 18:54:00 -04:00
Makefile.shlib Use -Bsymbolic for shared libraries on HP-UX and Solaris. 2018-09-10 22:22:12 -04:00
nls-global.mk nls-global.mk: search build dir for source files, too 2016-06-07 18:55:18 -04:00