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

Commite44735c

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 parentee8d377 commite44735c

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
@@ -1403,8 +1403,7 @@ ident_inet(hbaPort *port)
14031403
constSockAddrremote_addr=port->raddr;
14041404
constSockAddrlocal_addr=port->laddr;
14051405
charident_user[IDENT_USERNAME_MAX+1];
1406-
pgsocketsock_fd;/* File descriptor for socket on which we talk
1407-
* to Ident */
1406+
pgsocketsock_fd=PGINVALID_SOCKET;/* for talking to Ident server */
14081407
intrc;/* Return code from a locally called function */
14091408
boolident_return;
14101409
charremote_addr_s[NI_MAXHOST];
@@ -1443,9 +1442,9 @@ ident_inet(hbaPort *port)
14431442
rc=pg_getaddrinfo_all(remote_addr_s,ident_port,&hints,&ident_serv);
14441443
if (rc|| !ident_serv)
14451444
{
1446-
if (ident_serv)
1447-
pg_freeaddrinfo_all(hints.ai_family,ident_serv);
1448-
returnSTATUS_ERROR;/* we don't expect this to happen */
1445+
/* we don't expect this to happen */
1446+
ident_return= false;
1447+
gotoident_inet_done;
14491448
}
14501449

14511450
hints.ai_flags=AI_NUMERICHOST;
@@ -1459,9 +1458,9 @@ ident_inet(hbaPort *port)
14591458
rc=pg_getaddrinfo_all(local_addr_s,NULL,&hints,&la);
14601459
if (rc|| !la)
14611460
{
1462-
if (la)
1463-
pg_freeaddrinfo_all(hints.ai_family,la);
1464-
returnSTATUS_ERROR;/* we don't expect this to happen */
1461+
/* we don't expect this to happen */
1462+
ident_return= false;
1463+
gotoident_inet_done;
14651464
}
14661465

14671466
sock_fd=socket(ident_serv->ai_family,ident_serv->ai_socktype,
@@ -1548,8 +1547,10 @@ ident_inet(hbaPort *port)
15481547
ident_inet_done:
15491548
if (sock_fd!=PGINVALID_SOCKET)
15501549
closesocket(sock_fd);
1551-
pg_freeaddrinfo_all(remote_addr.addr.ss_family,ident_serv);
1552-
pg_freeaddrinfo_all(local_addr.addr.ss_family,la);
1550+
if (ident_serv)
1551+
pg_freeaddrinfo_all(remote_addr.addr.ss_family,ident_serv);
1552+
if (la)
1553+
pg_freeaddrinfo_all(local_addr.addr.ss_family,la);
15531554

15541555
if (ident_return)
15551556
/* Success! Check the usermap */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp