pgsql: Set snprintf.c's maximum number of NL arguments to be 31.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Set snprintf.c's maximum number of NL arguments to be 31.
Дата
Msg-id E1g7Nk4-0001cL-Ng@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
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

Branch
------
REL_11_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a051c19c3cf4415b36e6333a83a113de4d90a973

Modified Files
--------------
src/port/snprintf.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix corner-case failures in has_foo_privilege() family offuncti
Следующее
От: Andres Freund
Дата:
Сообщение: pgsql: Use slots more widely in tuple mapping code and make namingmore