Skip site navigation (1) Skip section navigation (2)

pgsql: Fix race condition in pg_ctl reading

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix race condition in pg_ctl reading
Date: 2012-10-15 07:59:54
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-committers
Fix race condition in pg_ctl reading

If postmaster changed 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.



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

pgsql-committers by date

Next:From: Heikki LinnakangasDate: 2012-10-15 08:04:07
Subject: pgsql: Remove comment that is no longer true.
Previous:From: Tom LaneDate: 2012-10-15 03:00:21
Subject: pgsql: Split up process latch initialization for more-fail-softbehavio

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group