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

Commit0a3094b

Browse files
committed
Reorder MD5/crypt so MD5 comes first in the code.
1 parent2637f88 commit0a3094b

File tree

3 files changed

+45
-45
lines changed

3 files changed

+45
-45
lines changed

‎src/backend/libpq/auth.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.60 2001/08/1702:59:19 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.61 2001/08/1715:40:07 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -420,8 +420,8 @@ auth_failed(Port *port)
420420
authmethod="IDENT";
421421
break;
422422
caseuaPassword:
423-
caseuaCrypt:
424423
caseuaMD5:
424+
caseuaCrypt:
425425
authmethod="Password";
426426
break;
427427
}
@@ -501,13 +501,13 @@ ClientAuthentication(Port *port)
501501
status=recv_and_check_password_packet(port);
502502
break;
503503

504-
caseuaCrypt:
505-
sendAuthRequest(port,AUTH_REQ_CRYPT);
504+
caseuaMD5:
505+
sendAuthRequest(port,AUTH_REQ_MD5);
506506
status=recv_and_check_password_packet(port);
507507
break;
508508

509-
caseuaMD5:
510-
sendAuthRequest(port,AUTH_REQ_MD5);
509+
caseuaCrypt:
510+
sendAuthRequest(port,AUTH_REQ_CRYPT);
511511
status=recv_and_check_password_packet(port);
512512
break;
513513

@@ -643,8 +643,8 @@ map_old_to_new(Port *port, UserAuth old, int status)
643643
{
644644
switch (port->auth_method)
645645
{
646-
caseuaCrypt:
647646
caseuaMD5:
647+
caseuaCrypt:
648648
caseuaReject:
649649
status=STATUS_ERROR;
650650
break;

‎src/backend/libpq/crypt.c

Lines changed: 8 additions & 8 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.36 2001/08/1703:09:31 momjian Exp $
12+
* $Id: crypt.c,v 1.37 2001/08/1715:40:07 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -294,13 +294,6 @@ md5_crypt_verify(const Port *port, const char *user, const char *pgpass)
294294
*/
295295
switch (port->auth_method)
296296
{
297-
caseuaCrypt:
298-
{
299-
charsalt[3];
300-
StrNCpy(salt,port->cryptSalt,3);
301-
crypt_pwd=crypt(passwd,salt);
302-
break;
303-
}
304297
caseuaMD5:
305298
crypt_pwd=palloc(MD5_PASSWD_LEN+1);
306299
if (isMD5(passwd))
@@ -334,6 +327,13 @@ md5_crypt_verify(const Port *port, const char *user, const char *pgpass)
334327
pfree(crypt_pwd2);
335328
}
336329
break;
330+
caseuaCrypt:
331+
{
332+
charsalt[3];
333+
StrNCpy(salt,port->cryptSalt,3);
334+
crypt_pwd=crypt(passwd,salt);
335+
break;
336+
}
337337
default:
338338
crypt_pwd=passwd;
339339
break;

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

Lines changed: 30 additions & 30 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.54 2001/08/17 15:11:15 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.55 2001/08/17 15:40:07 momjian Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -438,6 +438,33 @@ pg_password_sendauth(PGconn *conn, const char *password, AuthRequest areq)
438438

439439
switch (areq)
440440
{
441+
caseAUTH_REQ_MD5:
442+
{
443+
char*crypt_pwd2;
444+
445+
if (!(crypt_pwd=malloc(MD5_PASSWD_LEN+1))||
446+
!(crypt_pwd2=malloc(MD5_PASSWD_LEN+1)))
447+
{
448+
perror("malloc");
449+
returnSTATUS_ERROR;
450+
}
451+
if (!EncryptMD5(password,conn->pguser,
452+
strlen(conn->pguser),crypt_pwd2))
453+
{
454+
free(crypt_pwd);
455+
free(crypt_pwd2);
456+
returnSTATUS_ERROR;
457+
}
458+
if (!EncryptMD5(crypt_pwd2+strlen("md5"),conn->md5Salt,
459+
sizeof(conn->md5Salt),crypt_pwd))
460+
{
461+
free(crypt_pwd);
462+
free(crypt_pwd2);
463+
returnSTATUS_ERROR;
464+
}
465+
free(crypt_pwd2);
466+
break;
467+
}
441468
caseAUTH_REQ_CRYPT:
442469
{
443470
charsalt[3];
@@ -446,33 +473,6 @@ pg_password_sendauth(PGconn *conn, const char *password, AuthRequest areq)
446473
crypt_pwd=crypt(password,salt);
447474
break;
448475
}
449-
caseAUTH_REQ_MD5:
450-
{
451-
char*crypt_pwd2;
452-
453-
if (!(crypt_pwd=malloc(MD5_PASSWD_LEN+1))||
454-
!(crypt_pwd2=malloc(MD5_PASSWD_LEN+1)))
455-
{
456-
perror("malloc");
457-
returnSTATUS_ERROR;
458-
}
459-
if (!EncryptMD5(password,conn->pguser,
460-
strlen(conn->pguser),crypt_pwd2))
461-
{
462-
free(crypt_pwd);
463-
free(crypt_pwd2);
464-
returnSTATUS_ERROR;
465-
}
466-
if (!EncryptMD5(crypt_pwd2+strlen("md5"),conn->md5Salt,
467-
sizeof(conn->md5Salt),crypt_pwd))
468-
{
469-
free(crypt_pwd);
470-
free(crypt_pwd2);
471-
returnSTATUS_ERROR;
472-
}
473-
free(crypt_pwd2);
474-
break;
475-
}
476476
default:
477477
/* discard const so we can assign it */
478478
crypt_pwd= (char*)password;
@@ -535,9 +535,9 @@ fe_sendauth(AuthRequest areq, PGconn *conn, const char *hostname,
535535
returnSTATUS_ERROR;
536536
#endif
537537

538-
caseAUTH_REQ_PASSWORD:
539-
caseAUTH_REQ_CRYPT:
540538
caseAUTH_REQ_MD5:
539+
caseAUTH_REQ_CRYPT:
540+
caseAUTH_REQ_PASSWORD:
541541
if (password==NULL||*password=='\0')
542542
{
543543
(void)sprintf(PQerrormsg,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp