]> 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:54:26 +0000 (10:54 +0300)
commit6d934e4aaec1e7712e088a48d9fc02acc5be4d25
tree830f8bb3ae652a78d671218a1167e27b75cc82cf
parent55eaeef0b9314c40b7124ae37b33e0d61383bf3d
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