pgsql: Ensure maxlen is at leat 1 in dict_int

Поиск
Список
Период
Сортировка
От Tomas Vondra
Тема pgsql: Ensure maxlen is at leat 1 in dict_int
Дата
Msg-id E1icCCr-0006OW-LV@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Ensure maxlen is at leat 1 in dict_int

The dict_int text search dictionary template accepts maxlen parameter,
which is then used to cap the length of input strings. The value was
not properly checked, and the code simply does

    txt[d->maxlen] = '\0';

to insert a terminator, leading to segfaults with negative values.

This commit simply rejects values less than 1. The issue was there since
dct_int was introduced in 9.3, so backpatch all the way back to 9.4
which is the oldest supported version.

Reported-by: cili
Discussion: https://postgr.es/m/16144-a36a5bef7657047d@postgresql.org
Backpatch-through: 9.4

Branch
------
REL9_4_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/44381b1aff0e92acc91381c40f1b07514e93a18b

Modified Files
--------------
contrib/dict_int/dict_int.c            | 5 +++++
contrib/dict_int/expected/dict_int.out | 2 ++
contrib/dict_int/sql/dict_int.sql      | 2 ++
3 files changed, 9 insertions(+)


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

Предыдущее
От: Tomas Vondra
Дата:
Сообщение: pgsql: Ensure maxlen is at leat 1 in dict_int
Следующее
От: Michael Paquier
Дата:
Сообщение: pgsql: Remove unnecessary definition of CancelRequested in bin/scripts/