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

Commit0168fb0

Browse files
committed
Fix minor memory leak in ident_inet().
We'd leak the ident_serv data structure if the second pg_getaddrinfo_all(the one for the local address) failed. This is not of great consequencebecause a failure return here just leads directly to backend exit(), butif this function is going to try to clean up after itself at all, it shouldnot have such holes in the logic. Try to fix it in a future-proof way byhaving all the failure exits go through the same cleanup path, rather than"optimizing" some of them.Per Coverity. Back-patch to 9.2, which is as far back as this patchapplies cleanly.
1 parent8b63f89 commit0168fb0

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

‎src/backend/libpq/auth.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,8 +1613,7 @@ ident_inet(hbaPort *port)
16131613
constSockAddrremote_addr=port->raddr;
16141614
constSockAddrlocal_addr=port->laddr;
16151615
charident_user[IDENT_USERNAME_MAX+1];
1616-
pgsocketsock_fd;/* File descriptor for socket on which we talk
1617-
* to Ident */
1616+
pgsocketsock_fd=PGINVALID_SOCKET;/* for talking to Ident server */
16181617
intrc;/* Return code from a locally called function */
16191618
boolident_return;
16201619
charremote_addr_s[NI_MAXHOST];
@@ -1653,9 +1652,9 @@ ident_inet(hbaPort *port)
16531652
rc=pg_getaddrinfo_all(remote_addr_s,ident_port,&hints,&ident_serv);
16541653
if (rc|| !ident_serv)
16551654
{
1656-
if (ident_serv)
1657-
pg_freeaddrinfo_all(hints.ai_family,ident_serv);
1658-
returnSTATUS_ERROR;/* we don't expect this to happen */
1655+
/* we don't expect this to happen */
1656+
ident_return= false;
1657+
gotoident_inet_done;
16591658
}
16601659

16611660
hints.ai_flags=AI_NUMERICHOST;
@@ -1669,9 +1668,9 @@ ident_inet(hbaPort *port)
16691668
rc=pg_getaddrinfo_all(local_addr_s,NULL,&hints,&la);
16701669
if (rc|| !la)
16711670
{
1672-
if (la)
1673-
pg_freeaddrinfo_all(hints.ai_family,la);
1674-
returnSTATUS_ERROR;/* we don't expect this to happen */
1671+
/* we don't expect this to happen */
1672+
ident_return= false;
1673+
gotoident_inet_done;
16751674
}
16761675

16771676
sock_fd=socket(ident_serv->ai_family,ident_serv->ai_socktype,
@@ -1758,8 +1757,10 @@ ident_inet(hbaPort *port)
17581757
ident_inet_done:
17591758
if (sock_fd!=PGINVALID_SOCKET)
17601759
closesocket(sock_fd);
1761-
pg_freeaddrinfo_all(remote_addr.addr.ss_family,ident_serv);
1762-
pg_freeaddrinfo_all(local_addr.addr.ss_family,la);
1760+
if (ident_serv)
1761+
pg_freeaddrinfo_all(remote_addr.addr.ss_family,ident_serv);
1762+
if (la)
1763+
pg_freeaddrinfo_all(local_addr.addr.ss_family,la);
17631764

17641765
if (ident_return)
17651766
/* Success! Check the usermap */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp