pgpool2.git / summary / log / commit / refs

commit    44ec98418f3746dc0cea15e1bd7dfb9e7aaa1e48
Author:   Tatsuo Ishii <ishii@postgresql.org>
Date:     Sun Nov 17 04:44:48 2013 +0000

    Fix uninitialized variable in error case in pool_do_auth().
    
    If there's no valid backend, pgpool will return garbage pid to
    frontend in auth phase. Actually because no backend is available,
    frontend will be disconnected later on. So this is not harmless.
    Per Coverity report "1127331 Uninitialized scalar variable".


src/auth/pool_auth.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/auth/pool_auth.c b/src/auth/pool_auth.c index dd3fd1031..8d98dc510 100644 --- a/src/auth/pool_auth.c +++ b/src/auth/pool_auth.c @@ -347,6 +347,7 @@ from pool_read_message_length and recheck the pg_hba.conf settings."); * OK, read pid and secret key */ sp = MASTER_CONNECTION(cp)->sp; + pid = -1; for (i=0;i<NUM_BACKENDS;i++) { @@ -379,14 +380,12 @@ from pool_read_message_length and recheck the pg_hba.conf settings."); } } -#ifdef NOT_USED - sp = MASTER_CONNECTION(cp)->sp; - cp->info->major = sp->major; - cp->info->minor = sp->minor; - strncpy(cp->info->database, sp->database, sizeof(cp->info->database) - 1); - strncpy(cp->info->user, sp->user, sizeof(cp->info->user) - 1); - cp->info->counter = 1; -#endif + if (pid == -1) + { + pool_error("pool_do_auth: all backends are down"); + return -1; + } + return pool_send_backend_key_data(frontend, pid, key, protoMajor); } [parent: 2dbc72585c82]