Fix hostname length check in StartNodeUserDatabaseConnection (#4363)

Copying string before hostname length check makes the check useless
pull/4357/head^2
Onur Tirtir 2020-11-30 20:00:35 +03:00 committed by GitHub
parent 7f3d1182ed
commit 03bcccdee0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -257,7 +257,6 @@ StartNodeUserDatabaseConnection(uint32 flags, const char *hostname, int32 port,
bool found;
/* do some minimal input checks */
strlcpy(key.hostname, hostname, MAX_NODE_LENGTH);
if (strlen(hostname) > MAX_NODE_LENGTH)
{
ereport(ERROR, (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
@ -265,6 +264,8 @@ StartNodeUserDatabaseConnection(uint32 flags, const char *hostname, int32 port,
MAX_NODE_LENGTH)));
}
strlcpy(key.hostname, hostname, MAX_NODE_LENGTH);
key.port = port;
if (user)
{