Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc5e1df9

Browse files
committed
Remove one use of IDENT_USERNAME_MAX
IDENT_USERNAME_MAX is the maximum length of the information returnedby an ident server, per RFC 1413. Using it as the buffer size in peerauthentication is inappropriate. It was done here because of thehistorical relationship between peer and ident authentication. Toreduce confusion between the two authenticaton methods and disentangletheir code, use a dynamically allocated buffer instead.Discussion:https://www.postgresql.org/message-id/flat/c798fba5-8b71-4f27-c78e-37714037ea31%402ndquadrant.com
1 parent5cc1e64 commitc5e1df9

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

‎src/backend/libpq/auth.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static intCheckSCRAMAuth(Port *port, char *shadow_pass, char **logdetail);
6565
* Ident authentication
6666
*----------------------------------------------------------------
6767
*/
68-
/* Max size of username ident server can return */
68+
/* Max size of username ident server can return(per RFC 1413)*/
6969
#defineIDENT_USERNAME_MAX 512
7070

7171
/* Standard TCP port number for Ident service. Assigned by IANA */
@@ -1990,10 +1990,11 @@ ident_inet(hbaPort *port)
19901990
staticint
19911991
auth_peer(hbaPort*port)
19921992
{
1993-
charident_user[IDENT_USERNAME_MAX+1];
19941993
uid_tuid;
19951994
gid_tgid;
19961995
structpasswd*pw;
1996+
char*peer_user;
1997+
intret;
19971998

19981999
if (getpeereid(port->sock,&uid,&gid)!=0)
19992000
{
@@ -2022,9 +2023,14 @@ auth_peer(hbaPort *port)
20222023
returnSTATUS_ERROR;
20232024
}
20242025

2025-
strlcpy(ident_user,pw->pw_name,IDENT_USERNAME_MAX+1);
2026+
/* Make a copy of static getpw*() result area. */
2027+
peer_user=pstrdup(pw->pw_name);
2028+
2029+
ret=check_usermap(port->hba->usermap,port->user_name,peer_user, false);
20262030

2027-
returncheck_usermap(port->hba->usermap,port->user_name,ident_user, false);
2031+
pfree(peer_user);
2032+
2033+
returnret;
20282034
}
20292035
#endif/* HAVE_UNIX_SOCKETS */
20302036

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp