pgpool2.git / summary / log / commit / refs
commit 522ef0b7d5738cc9ca95c4655c70913d5b6790cc
Author: Tatsuo Ishii <ishii@postgresql.org>
Commit: Muhammad Usama <m.usama@gmail.com>
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 | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/src/auth/pool_auth.c b/src/auth/pool_auth.c
index c2aa5fe94..8cda37e97 100644
--- a/src/auth/pool_auth.c
+++ b/src/auth/pool_auth.c
@@ -372,6 +372,7 @@ int pool_do_auth(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp)
* OK, read pid and secret key
*/
sp = MASTER_CONNECTION(cp)->sp;
+ pid = -1;
for (i=0;i<NUM_BACKENDS;i++)
{
@@ -406,18 +407,15 @@ int pool_do_auth(POOL_CONNECTION *frontend, POOL_CONNECTION_POOL *cp)
}
}
-#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)
+ ereport(ERROR,
+ (errmsg("authentication failed"),
+ errdetail("all backends are down")));
+
if(pool_send_backend_key_data(frontend, pid, key, protoMajor))
ereport(ERROR,
(errmsg("authentication failed"),
- errdetail("failed to send backend data to frontedn")));
+ errdetail("failed to send backend data to frontend")));
return 0;
}
[parent: 4ed9fbd6bbe9]