postgresql/src/backend/utils/mb
Noah Misch cbadeaca92 With GB18030, prevent SIGSEGV from reading past end of allocation.
With GB18030 as source encoding, applications could crash the server via
SQL functions convert() or convert_from().  Applications themselves
could crash after passing unterminated GB18030 input to libpq functions
PQescapeLiteral(), PQescapeIdentifier(), PQescapeStringConn(), or
PQescapeString().  Extension code could crash by passing unterminated
GB18030 input to jsonapi.h functions.  All those functions have been
intended to handle untrusted, unterminated input safely.

A crash required allocating the input such that the last byte of the
allocation was the last byte of a virtual memory page.  Some malloc()
implementations take measures against that, making the SIGSEGV hard to
reach.  Back-patch to v13 (all supported versions).

Author: Noah Misch <noah@leadboat.com>
Author: Andres Freund <andres@anarazel.de>
Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com>
Backpatch-through: 13
Security: CVE-2025-4207
2025-05-05 04:52:08 -07:00
..
conversion_procs Update copyrights for 2020 2020-01-01 12:21:45 -05:00
Unicode Use perl warnings pragma consistently 2020-04-13 11:55:45 -04:00
conv.c Rationalize code placement between wchar.c, encnames.c, and mbutils.c. 2020-01-16 18:08:21 -05:00
iso.c Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
Makefile Move wchar.c and encnames.c to src/common/. 2020-01-16 15:58:55 -05:00
mbutils.c With GB18030, prevent SIGSEGV from reading past end of allocation. 2025-05-05 04:52:08 -07:00
README Move wchar.c and encnames.c to src/common/. 2020-01-16 15:58:55 -05:00
stringinfo_mb.c Improve user control over truncation of logged bind-parameter values. 2020-04-02 15:04:51 -04:00
win866.c Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
win1251.c Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
wstrcmp.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00
wstrncmp.c pgindent run for 9.4 2014-05-06 12:12:18 -04:00

src/backend/utils/mb/README

Encodings
=========

conv.c:		static functions and a public table for code conversion
mbutils.c:	public functions for the backend only.
stringinfo_mb.c: public backend-only multibyte-aware stringinfo functions
wstrcmp.c:	strcmp for mb
wstrncmp.c:	strncmp for mb
win866.c:	a tool to generate KOI8 <--> CP866 conversion table
iso.c:		a tool to generate KOI8 <--> ISO8859-5 conversion table
win1251.c:	a tool to generate KOI8 <--> CP1251 conversion table

See also in src/common/:

encnames.c:	public functions for encoding names
wchar.c:	mostly static functions and a public table for mb string and
		multibyte conversion

Introduction
------------
	http://www.cprogramming.com/tutorial/unicode.html