]> 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:33 +0000 (10:54 +0300)
commit1c95b5eea6bec742d5d6ee097c55690712dd3be6
treefb7c1706e3059b5f8b05a7a5c3f2195c2c43922a
parent5c07de4bdfadd2ea73c66dcad3b0e4d5ca4ceef7
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