• Heikki Linnakangas's avatar
    Fix race condition in pg_ctl reading postmaster.pid. · 5c89684e
    Heikki Linnakangas authored
    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.
    5c89684e
pg_ctl.c 58.4 KB