pgpool2.git / summary / log / commit / refs

commit    77eda4223423c8ee2ebd53078a79b523f241a9f2
Author:   Tatsuo Ishii <ishii@postgresql.org>
Date:     Tue Nov 19 06:25:05 2013 +0000

    Fix to add node id range check when issue an error message using node id.
    
    Per Coverity report #1111433 "Out-of-bounds read".


src/main/main.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/main.c b/src/main/main.c index 8e78c5079..553b7241b 100644 --- a/src/main/main.c +++ b/src/main/main.c @@ -1752,14 +1752,18 @@ static void failover(void) /* failback request? */ if (Req_info->kind == NODE_UP_REQUEST) { - if (node_id >= MAX_NUM_BACKENDS || + if (node_id < 0 || node_id >= MAX_NUM_BACKENDS || (Req_info->kind == NODE_UP_REQUEST && !(RAW_MODE && BACKEND_INFO(node_id).backend_status == CON_DOWN) && VALID_BACKEND(node_id)) || (Req_info->kind == NODE_DOWN_REQUEST && !VALID_BACKEND(node_id))) { pool_semaphore_unlock(REQUEST_INFO_SEM); - pool_error("failover_handler: invalid node_id %d status:%d MAX_NUM_BACKENDS: %d", node_id, - BACKEND_INFO(node_id).backend_status, MAX_NUM_BACKENDS); + + if (node_id < 0 || node_id >= MAX_NUM_BACKENDS) + pool_error("failover_handler: invalid node_id %d MAX_NUM_BACKENDS: %d", node_id, MAX_NUM_BACKENDS); + else + pool_error("failover_handler: invalid node_id %d status:%d MAX_NUM_BACKENDS: %d", node_id, + BACKEND_INFO(node_id).backend_status, MAX_NUM_BACKENDS); kill(pcp_pid, SIGUSR2); switching = 0; Req_info->switching = false; [parent: 15a495009497]