pgpool2.git / summary / log / commit / refs

commit    d662d4cbda9db040780193c489066dbb5922a8f5
Author:   Tatsuo Ishii <ishii@sraoss.co.jp>
Date:     Fri Aug 21 10:51:04 2020 +0000

    Fix sefault in pgpool child process in certain case.
    
    When all backend go down, pgpool refuses to accept connection from
    clients and try to send a message in
    validate_backend_connectivity(). For this purpose it connects to the
    client and try to read the startup packet. This is done in a PG_TRY
    block. The startup packet is read in memory pointed to by "sp", which
    is declared as "StartupPacket *volatile". This is fine. But it was
    forgotten to initialize the value with NULL. As a result, if reading
    startup packet fails, sp would be garbage a pointer and segfaults later
    in pool_free_startup_packet(sp).
    
    Fix is, initialize "sp" with NULL.
    
    I have found this accidentally in following way:
    
    1) shutdown all backends.
    
    2) connect to pgpool with invalid client. I have used pcp_attach_node
    with pgpool's port number, not pcp's.


src/protocol/child.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/protocol/child.c b/src/protocol/child.c index a064a5962..a20d3018f 100644 --- a/src/protocol/child.c +++ b/src/protocol/child.c @@ -1707,7 +1707,7 @@ validate_backend_connectivity(int front_end_fd) if (front_end_fd > 0) { POOL_CONNECTION *cp; - StartupPacket *volatile sp; + StartupPacket *volatile sp = NULL; /* * we do not want to report socket error, as above errors will be [parent: 777fd7a3210a]