Commit 3cb282f3 authored by Tom Lane's avatar Tom Lane

Guard against array overrun, per report from Yichen Xie. This case

can only occur if the constant DEFAULT_CLIENT_AUTHSVC is given a bogus
value, so it doesn't seem worth back-patching, but I'll fix it in HEAD.
parent 23b8a0ce
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes). * exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.72 2002/12/03 22:09:20 momjian Exp $ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.73 2003/01/29 01:18:21 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -686,7 +686,14 @@ MsgType ...@@ -686,7 +686,14 @@ MsgType
fe_getauthsvc(char *PQerrormsg) fe_getauthsvc(char *PQerrormsg)
{ {
if (pg_authsvc < 0 || pg_authsvc >= n_authsvcs) if (pg_authsvc < 0 || pg_authsvc >= n_authsvcs)
{
fe_setauthsvc(DEFAULT_CLIENT_AUTHSVC, PQerrormsg); fe_setauthsvc(DEFAULT_CLIENT_AUTHSVC, PQerrormsg);
if (pg_authsvc < 0 || pg_authsvc >= n_authsvcs)
{
/* Can only get here if DEFAULT_CLIENT_AUTHSVC is misdefined */
return 0;
}
}
return authsvcs[pg_authsvc].msgtype; return authsvcs[pg_authsvc].msgtype;
} }
...@@ -704,6 +711,10 @@ fe_getauthname(char *PQerrormsg) ...@@ -704,6 +711,10 @@ fe_getauthname(char *PQerrormsg)
authsvc = fe_getauthsvc(PQerrormsg); authsvc = fe_getauthsvc(PQerrormsg);
/* this just guards against broken DEFAULT_CLIENT_AUTHSVC, see above */
if (authsvc == 0)
return NULL; /* leave original error message in place */
#ifdef KRB4 #ifdef KRB4
if (authsvc == STARTUP_KRB4_MSG) if (authsvc == STARTUP_KRB4_MSG)
name = pg_krb4_authname(PQerrormsg); name = pg_krb4_authname(PQerrormsg);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment