Fix string truncation to be multibyte-aware in text_name and bpchar_name.

Tom Lane <tgl@sss.pgh.pa.us>

Commit: 2a7c90c83bc5b668764faae643b9f3d8c652667a
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2012-05-25T21:35:14Z
Releases: 8.4.12
Fix string truncation to be multibyte-aware in text_name and bpchar_name.

Previously, casts to name could generate invalidly-encoded results.

Also, make these functions match namein() more exactly, by consistently
using palloc0() instead of ad-hoc zeroing code.

Back-patch to all supported branches.

Karl Schnaitter and Tom Lane

Files

PathChange+/−
src/backend/utils/adt/name.c modified +7 −3
src/backend/utils/adt/varchar.c modified +4 −10
src/backend/utils/adt/varlena.c modified +3 −9