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

Commit f81ce4a

Browse files
committed
Prevent problem with extra-long password packets from allocating lots of
memory. Neil Conway
1 parent 626eca6 commit f81ce4a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/backend/libpq/auth.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.86 2002/08/29 03:22:01 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.87 2002/08/29 21:50:36 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -709,6 +709,20 @@ recv_and_check_password_packet(Port *port)
709709
if (pq_eof() == EOF || pq_getint(&len, 4) == EOF)
710710
return STATUS_EOF; /* client didn't want to send password */
711711

712+
/*
713+
* Since the remote client has not yet been authenticated, we need
714+
* to be careful when using the data they send us. The 8K limit is
715+
* arbitrary, and somewhat bogus: the intent is to ensure we don't
716+
* allocate an enormous chunk of memory.
717+
*/
718+
719+
if (len < 1 || len > 8192)
720+
{
721+
elog(LOG, "Invalid password packet length: %d; "
722+
"must satisfy 1 <= length <= 8192", len);
723+
return STATUS_EOF;
724+
}
725+
712726
initStringInfo(&buf);
713727
if (pq_getstr(&buf) == EOF) /* receive password */
714728
{

0 commit comments

Comments
 (0)