Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 3cb282f

Browse files
committed
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.
1 parent 23b8a0c commit 3cb282f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/interfaces/libpq/fe-auth.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.72 2002/12/03 22:09:20 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.73 2003/01/29 01:18:21 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -686,7 +686,14 @@ MsgType
686686
fe_getauthsvc(char *PQerrormsg)
687687
{
688688
if (pg_authsvc < 0 || pg_authsvc >= n_authsvcs)
689+
{
689690
fe_setauthsvc(DEFAULT_CLIENT_AUTHSVC, PQerrormsg);
691+
if (pg_authsvc < 0 || pg_authsvc >= n_authsvcs)
692+
{
693+
/* Can only get here if DEFAULT_CLIENT_AUTHSVC is misdefined */
694+
return 0;
695+
}
696+
}
690697
return authsvcs[pg_authsvc].msgtype;
691698
}
692699

@@ -704,6 +711,10 @@ fe_getauthname(char *PQerrormsg)
704711

705712
authsvc = fe_getauthsvc(PQerrormsg);
706713

714+
/* this just guards against broken DEFAULT_CLIENT_AUTHSVC, see above */
715+
if (authsvc == 0)
716+
return NULL; /* leave original error message in place */
717+
707718
#ifdef KRB4
708719
if (authsvc == STARTUP_KRB4_MSG)
709720
name = pg_krb4_authname(PQerrormsg);

0 commit comments

Comments
 (0)