Commit d18c1d1f authored by Tom Lane's avatar Tom Lane

Truncate incoming username and database name to NAMEDATALEN-1 characters

so that we don't reject overlength names unnecessarily.
parent 72fa2426
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.207 2001/02/11 23:12:28 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.208 2001/02/20 01:34:40 tgl Exp $
* *
* NOTES * NOTES
* *
...@@ -1123,6 +1123,14 @@ readStartupPacket(void *arg, PacketLen len, void *pkt) ...@@ -1123,6 +1123,14 @@ readStartupPacket(void *arg, PacketLen len, void *pkt)
if (port->database[0] == '\0') if (port->database[0] == '\0')
StrNCpy(port->database, si->user, sizeof(port->database)); StrNCpy(port->database, si->user, sizeof(port->database));
/* Truncate given database and user names to length of a Postgres name. */
/* This avoids lookup failures when overlength names are given. */
if ((int) sizeof(port->database) >= NAMEDATALEN)
port->database[NAMEDATALEN-1] = '\0';
if ((int) sizeof(port->user) >= NAMEDATALEN)
port->user[NAMEDATALEN-1] = '\0';
/* Check a user name was given. */ /* Check a user name was given. */
if (port->user[0] == '\0') if (port->user[0] == '\0')
......
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