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

Commite685a8e

Browse files
committed
libpq: Small code clarification, and avoid casting away const
1 parent19dbc34 commite685a8e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,8 @@ static int
739739
pg_password_sendauth(PGconn*conn,constchar*password,AuthRequestareq)
740740
{
741741
intret;
742-
char*crypt_pwd;
742+
char*crypt_pwd=NULL;
743+
constchar*pwd_to_send;
743744

744745
/* Encrypt the password if needed. */
745746

@@ -771,21 +772,22 @@ pg_password_sendauth(PGconn *conn, const char *password, AuthRequest areq)
771772
free(crypt_pwd);
772773
returnSTATUS_ERROR;
773774
}
775+
776+
pwd_to_send=crypt_pwd;
774777
break;
775778
}
776779
caseAUTH_REQ_PASSWORD:
777-
/* discard const so we can assign it */
778-
crypt_pwd= (char*)password;
780+
pwd_to_send=password;
779781
break;
780782
default:
781783
returnSTATUS_ERROR;
782784
}
783785
/* Packet has a message type as of protocol 3.0 */
784786
if (PG_PROTOCOL_MAJOR(conn->pversion) >=3)
785-
ret=pqPacketSend(conn,'p',crypt_pwd,strlen(crypt_pwd)+1);
787+
ret=pqPacketSend(conn,'p',pwd_to_send,strlen(pwd_to_send)+1);
786788
else
787-
ret=pqPacketSend(conn,0,crypt_pwd,strlen(crypt_pwd)+1);
788-
if (areq==AUTH_REQ_MD5)
789+
ret=pqPacketSend(conn,0,pwd_to_send,strlen(pwd_to_send)+1);
790+
if (crypt_pwd)
789791
free(crypt_pwd);
790792
returnret;
791793
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp