mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-02-11 19:20:40 +08:00
Truncate incoming username and database name to NAMEDATALEN-1 characters
so that we don't reject overlength names unnecessarily.
This commit is contained in:
parent
72fa2426fd
commit
d18c1d1f51
@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* 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
|
||||
*
|
||||
@ -1123,6 +1123,14 @@ readStartupPacket(void *arg, PacketLen len, void *pkt)
|
||||
if (port->database[0] == '\0')
|
||||
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. */
|
||||
|
||||
if (port->user[0] == '\0')
|
||||
|
Loading…
Reference in New Issue
Block a user