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

Commitb5453fa

Browse files
committed
Force crypt() salt to be null-terminated.
1 parentda45a0b commitb5453fa

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

‎src/backend/libpq/crypt.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Dec 17, 1997 - Todd A. Brandys
1010
*Orignal Version Completed.
1111
*
12-
* $Id: crypt.c,v 1.35 2001/08/1702:59:19 momjian Exp $
12+
* $Id: crypt.c,v 1.36 2001/08/1703:09:31 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -281,7 +281,7 @@ md5_crypt_verify(const Port *port, const char *user, const char *pgpass)
281281
if (isMD5(passwd)&&port->auth_method!=uaMD5)
282282
{
283283
snprintf(PQerrormsg,PQERRORMSG_LENGTH,
284-
"Password is stored MD5 encrypted. "
284+
"Password is stored MD5 encrypted. "
285285
"Only pg_hba.conf's MD5 protocol can be used for this user.\n");
286286
fputs(PQerrormsg,stderr);
287287
pqdebug("%s",PQerrormsg);
@@ -295,8 +295,12 @@ md5_crypt_verify(const Port *port, const char *user, const char *pgpass)
295295
switch (port->auth_method)
296296
{
297297
caseuaCrypt:
298-
crypt_pwd=crypt(passwd,port->cryptSalt);
298+
{
299+
charsalt[3];
300+
StrNCpy(salt,port->cryptSalt,3);
301+
crypt_pwd=crypt(passwd,salt);
299302
break;
303+
}
300304
caseuaMD5:
301305
crypt_pwd=palloc(MD5_PASSWD_LEN+1);
302306
if (isMD5(passwd))

‎src/interfaces/libpq/fe-auth.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* exceed INITIAL_EXPBUFFER_SIZE (currently 256 bytes).
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.51 2001/08/1702:59:19 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.52 2001/08/1703:09:31 momjian Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -443,8 +443,13 @@ pg_password_sendauth(PGconn *conn, const char *password, AuthRequest areq)
443443
switch (areq)
444444
{
445445
caseAUTH_REQ_CRYPT:
446-
crypt_pwd=crypt(password,conn->cryptSalt);
446+
{
447+
charsalt[3];
448+
449+
StrNCpy(salt,conn->cryptSalt,3);
450+
crypt_pwd=crypt(password,salt);
447451
break;
452+
}
448453
caseAUTH_REQ_MD5:
449454
{
450455
char*crypt_pwd2;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp