mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-30 19:41:17 +02:00
libpq: Small code clarification, and avoid casting away const
This commit is contained in:
parent
19dbc34631
commit
e685a8e665
@ -739,7 +739,8 @@ static int
|
|||||||
pg_password_sendauth(PGconn *conn, const char *password, AuthRequest areq)
|
pg_password_sendauth(PGconn *conn, const char *password, AuthRequest areq)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
char *crypt_pwd;
|
char *crypt_pwd = NULL;
|
||||||
|
const char *pwd_to_send;
|
||||||
|
|
||||||
/* Encrypt the password if needed. */
|
/* Encrypt the password if needed. */
|
||||||
|
|
||||||
@ -771,21 +772,22 @@ pg_password_sendauth(PGconn *conn, const char *password, AuthRequest areq)
|
|||||||
free(crypt_pwd);
|
free(crypt_pwd);
|
||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pwd_to_send = crypt_pwd;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AUTH_REQ_PASSWORD:
|
case AUTH_REQ_PASSWORD:
|
||||||
/* discard const so we can assign it */
|
pwd_to_send = password;
|
||||||
crypt_pwd = (char *) password;
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
}
|
}
|
||||||
/* Packet has a message type as of protocol 3.0 */
|
/* Packet has a message type as of protocol 3.0 */
|
||||||
if (PG_PROTOCOL_MAJOR(conn->pversion) >= 3)
|
if (PG_PROTOCOL_MAJOR(conn->pversion) >= 3)
|
||||||
ret = pqPacketSend(conn, 'p', crypt_pwd, strlen(crypt_pwd) + 1);
|
ret = pqPacketSend(conn, 'p', pwd_to_send, strlen(pwd_to_send) + 1);
|
||||||
else
|
else
|
||||||
ret = pqPacketSend(conn, 0, crypt_pwd, strlen(crypt_pwd) + 1);
|
ret = pqPacketSend(conn, 0, pwd_to_send, strlen(pwd_to_send) + 1);
|
||||||
if (areq == AUTH_REQ_MD5)
|
if (crypt_pwd)
|
||||||
free(crypt_pwd);
|
free(crypt_pwd);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user