pgsql: Fix race condition in pg_ctl reading postmaster.pid.

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема pgsql: Fix race condition in pg_ctl reading postmaster.pid.
Дата
Msg-id E1TNfac-0008O3-Tt@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix race condition in pg_ctl reading postmaster.pid.

If postmaster changed postmaster.pid while pg_ctl was reading it, pg_ctl
could overrun the buffer it allocated for the file. Fix by reading the
whole file to memory with one read() call.

initdb contains an identical copy of the readfile() function, but the files
that initdb reads are static, not modified concurrently. Nevertheless, add
a simple bounds-check there, if only to silence static analysis tools.

Per report from Dave Vitek. Backpatch to all supported branches.

Branch
------
REL8_3_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/17901b013709a0e46056b20001ee620016a286c6

Modified Files
--------------
src/bin/initdb/initdb.c |   12 +++----
src/bin/pg_ctl/pg_ctl.c |   88 +++++++++++++++++++++++++++++++----------------
2 files changed, 63 insertions(+), 37 deletions(-)


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

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: pgsql: Fix race condition in pg_ctl reading postmaster.pid.
Следующее
От: Heikki Linnakangas
Дата:
Сообщение: pgsql: Remove comment that is no longer true.