]> granicus.if.org Git - postgresql/commit
Fix race condition in pg_ctl reading postmaster.pid.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Sat, 13 Oct 2012 09:48:14 +0000 (12:48 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Mon, 15 Oct 2012 07:43:52 +0000 (10:43 +0300)
commit540374768d75b8f0b477274dc98c7c52602b2923
treeb195ba37c576c5d0ef015913ffee7bdf0bbfefa0
parent4d4005cb48f5d48d059bf90b849a43299881c3be
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.
src/bin/initdb/initdb.c
src/bin/pg_ctl/pg_ctl.c