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

Commitbcf2dec

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 parent5ea8cfe commitbcf2dec

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
@@ -1616,8 +1616,7 @@ ident_inet(hbaPort *port)
16161616
constSockAddrremote_addr=port->raddr;
16171617
constSockAddrlocal_addr=port->laddr;
16181618
charident_user[IDENT_USERNAME_MAX+1];
1619-
pgsocketsock_fd;/* File descriptor for socket on which we talk
1620-
* to Ident */
1619+
pgsocketsock_fd=PGINVALID_SOCKET;/* for talking to Ident server */
16211620
intrc;/* Return code from a locally called function */
16221621
boolident_return;
16231622
charremote_addr_s[NI_MAXHOST];
@@ -1656,9 +1655,9 @@ ident_inet(hbaPort *port)
16561655
rc=pg_getaddrinfo_all(remote_addr_s,ident_port,&hints,&ident_serv);
16571656
if (rc|| !ident_serv)
16581657
{
1659-
if (ident_serv)
1660-
pg_freeaddrinfo_all(hints.ai_family,ident_serv);
1661-
returnSTATUS_ERROR;/* we don't expect this to happen */
1658+
/* we don't expect this to happen */
1659+
ident_return= false;
1660+
gotoident_inet_done;
16621661
}
16631662

16641663
hints.ai_flags=AI_NUMERICHOST;
@@ -1672,9 +1671,9 @@ ident_inet(hbaPort *port)
16721671
rc=pg_getaddrinfo_all(local_addr_s,NULL,&hints,&la);
16731672
if (rc|| !la)
16741673
{
1675-
if (la)
1676-
pg_freeaddrinfo_all(hints.ai_family,la);
1677-
returnSTATUS_ERROR;/* we don't expect this to happen */
1674+
/* we don't expect this to happen */
1675+
ident_return= false;
1676+
gotoident_inet_done;
16781677
}
16791678

16801679
sock_fd=socket(ident_serv->ai_family,ident_serv->ai_socktype,
@@ -1761,8 +1760,10 @@ ident_inet(hbaPort *port)
17611760
ident_inet_done:
17621761
if (sock_fd!=PGINVALID_SOCKET)
17631762
closesocket(sock_fd);
1764-
pg_freeaddrinfo_all(remote_addr.addr.ss_family,ident_serv);
1765-
pg_freeaddrinfo_all(local_addr.addr.ss_family,la);
1763+
if (ident_serv)
1764+
pg_freeaddrinfo_all(remote_addr.addr.ss_family,ident_serv);
1765+
if (la)
1766+
pg_freeaddrinfo_all(local_addr.addr.ss_family,la);
17661767

17671768
if (ident_return)
17681769
/* Success! Check the usermap */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp