mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
Fix some minor resource leaks in PerformRadiusTransaction().
Failure to free serveraddrs pointed out by Coverity, failure to close socket noted by code-reading. These bugs seem to be quite old, but given the low probability of taking these error-exit paths and the minimal consequences of the leaks (since the process would presumably exit shortly anyway), it doesn't seem worth back-patching. Michael Paquier and Tom Lane
This commit is contained in:
@ -2793,6 +2793,7 @@ PerformRadiusTransaction(char *server, char *secret, char *portstr, char *identi
|
|||||||
{
|
{
|
||||||
ereport(LOG,
|
ereport(LOG,
|
||||||
(errmsg("could not generate random encryption vector")));
|
(errmsg("could not generate random encryption vector")));
|
||||||
|
pg_freeaddrinfo_all(hint.ai_family, serveraddrs);
|
||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
}
|
}
|
||||||
packet->id = packet->vector[0];
|
packet->id = packet->vector[0];
|
||||||
@ -2827,6 +2828,7 @@ PerformRadiusTransaction(char *server, char *secret, char *portstr, char *identi
|
|||||||
ereport(LOG,
|
ereport(LOG,
|
||||||
(errmsg("could not perform MD5 encryption of password")));
|
(errmsg("could not perform MD5 encryption of password")));
|
||||||
pfree(cryptvector);
|
pfree(cryptvector);
|
||||||
|
pg_freeaddrinfo_all(hint.ai_family, serveraddrs);
|
||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2842,7 +2844,7 @@ PerformRadiusTransaction(char *server, char *secret, char *portstr, char *identi
|
|||||||
|
|
||||||
radius_add_attribute(packet, RADIUS_PASSWORD, encryptedpassword, encryptedpasswordlen);
|
radius_add_attribute(packet, RADIUS_PASSWORD, encryptedpassword, encryptedpasswordlen);
|
||||||
|
|
||||||
/* Length need to be in network order on the wire */
|
/* Length needs to be in network order on the wire */
|
||||||
packetlength = packet->length;
|
packetlength = packet->length;
|
||||||
packet->length = htons(packet->length);
|
packet->length = htons(packet->length);
|
||||||
|
|
||||||
@ -2868,6 +2870,7 @@ PerformRadiusTransaction(char *server, char *secret, char *portstr, char *identi
|
|||||||
localaddr.sin_addr.s_addr = INADDR_ANY;
|
localaddr.sin_addr.s_addr = INADDR_ANY;
|
||||||
addrsize = sizeof(struct sockaddr_in);
|
addrsize = sizeof(struct sockaddr_in);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (bind(sock, (struct sockaddr *) & localaddr, addrsize))
|
if (bind(sock, (struct sockaddr *) & localaddr, addrsize))
|
||||||
{
|
{
|
||||||
ereport(LOG,
|
ereport(LOG,
|
||||||
@ -2964,6 +2967,7 @@ PerformRadiusTransaction(char *server, char *secret, char *portstr, char *identi
|
|||||||
{
|
{
|
||||||
ereport(LOG,
|
ereport(LOG,
|
||||||
(errmsg("could not read RADIUS response: %m")));
|
(errmsg("could not read RADIUS response: %m")));
|
||||||
|
closesocket(sock);
|
||||||
return STATUS_ERROR;
|
return STATUS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user