Guard against overly-long numeric formatting symbols from locale.

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

Commit: c97a2861851d3f92fb235ec80bd426b3f5a3d28c
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2026-04-22T16:41:00Z
Releases: 17.10
Guard against overly-long numeric formatting symbols from locale.

to_char() allocates its output buffer with 8 bytes per formatting
code in the pattern.  If the locale's currency symbol, thousands
separator, or decimal or sign symbol is more than 8 bytes long,
in principle we could overrun the output buffer.  No such locales
exist in the real world, so it seems sufficient to truncate the
symbol if we do see it's too long.

Reported-by: Xint Code
Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/638232.1776790821@sss.pgh.pa.us
Backpatch-through: 14

Files

PathChange+/−
src/backend/utils/adt/formatting.c modified +43 −18

Discussion