postgres/src
Tom Lane 4ed6dc7d4b Set snprintf.c's maximum number of NL arguments to be 31.
Previously, we used the platform's NL_ARGMAX if any, otherwise 16.
The trouble with this is that the platform value is hugely variable,
ranging from the POSIX-minimum 9 to as much as 64K on recent FreeBSD.
Values of more than a dozen or two have no practical use and slow down
the initialization of the argtypes array.  Worse, they cause snprintf.c
to consume far more stack space than was the design intention, possibly
resulting in stack-overflow crashes.

Standardize on 31, which is comfortably more than we need (it looks like
no existing translatable message has more than about 10 parameters).
I chose that, not 32, to make the array sizes powers of 2, for some
possible small gain in speed of the memset.

The lack of reported crashes suggests that the set of platforms we
use snprintf.c on (in released branches) may have no overlap with
the set where NL_ARGMAX has unreasonably large values.  But that's
not entirely clear, so back-patch to all supported branches.

Per report from Mateusz Guzik (via Thomas Munro).

Discussion: https://postgr.es/m/CAEepm=3VF=PUp2f8gU8fgZB22yPE_KBS0+e1AHAtQ=09schTHg@mail.gmail.com
2018-10-02 12:41:28 -04:00
..
backend Fix corner-case failures in has_foo_privilege() family of functions. 2018-10-02 11:54:13 -04:00
bin Support building with Visual Studio 2015 2018-09-11 15:46:35 -04:00
common Unlink static libraries before rebuilding them. 2015-03-01 13:06:39 -05:00
include Fix detection of the result type of strerror_r(). 2018-09-30 16:24:56 -04:00
interfaces Reduce an unnecessary O(N^3) loop in lexer. 2018-08-23 21:29:15 +01:00
makefiles Prevent accidental linking of system-supplied copies of libpq.so etc. 2018-07-09 17:23:32 -04:00
pl Make some fixes to allow building Postgres on macOS 10.14 ("Mojave"). 2018-09-25 13:23:29 -04:00
port Set snprintf.c's maximum number of NL arguments to be 31. 2018-10-02 12:41:28 -04:00
template Make some fixes to allow building Postgres on macOS 10.14 ("Mojave"). 2018-09-25 13:23:29 -04:00
test Fix corner-case failures in has_foo_privilege() family of functions. 2018-10-02 11:54:13 -04:00
timezone Update time zone data files to tzdata release 2018e. 2018-05-09 13:56:06 -04:00
tools Support building with Visual Studio 2017 2018-09-11 16:05:20 -04:00
tutorial Remove tabs after spaces in C comments 2014-05-06 11:26:28 -04:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
bcc32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
DEVELOPERS
Makefile Create libpgcommon, and move pg_malloc et al to it 2013-02-12 11:21:05 -03:00
Makefile.global.in Make some fixes to allow building Postgres on macOS 10.14 ("Mojave"). 2018-09-25 13:23:29 -04:00
Makefile.shlib Prevent accidental linking of system-supplied copies of libpq.so etc. 2018-07-09 17:23:32 -04:00
nls-global.mk nls-global.mk: search build dir for source files, too 2016-06-07 18:55:18 -04:00
win32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00