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

Commit58146d3

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 parent9179444 commit58146d3

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
@@ -1405,8 +1405,7 @@ ident_inet(hbaPort *port)
14051405
constSockAddrremote_addr=port->raddr;
14061406
constSockAddrlocal_addr=port->laddr;
14071407
charident_user[IDENT_USERNAME_MAX+1];
1408-
pgsocketsock_fd;/* File descriptor for socket on which we talk
1409-
* to Ident */
1408+
pgsocketsock_fd=PGINVALID_SOCKET;/* for talking to Ident server */
14101409
intrc;/* Return code from a locally called function */
14111410
boolident_return;
14121411
charremote_addr_s[NI_MAXHOST];
@@ -1445,9 +1444,9 @@ ident_inet(hbaPort *port)
14451444
rc=pg_getaddrinfo_all(remote_addr_s,ident_port,&hints,&ident_serv);
14461445
if (rc|| !ident_serv)
14471446
{
1448-
if (ident_serv)
1449-
pg_freeaddrinfo_all(hints.ai_family,ident_serv);
1450-
returnSTATUS_ERROR;/* we don't expect this to happen */
1447+
/* we don't expect this to happen */
1448+
ident_return= false;
1449+
gotoident_inet_done;
14511450
}
14521451

14531452
hints.ai_flags=AI_NUMERICHOST;
@@ -1461,9 +1460,9 @@ ident_inet(hbaPort *port)
14611460
rc=pg_getaddrinfo_all(local_addr_s,NULL,&hints,&la);
14621461
if (rc|| !la)
14631462
{
1464-
if (la)
1465-
pg_freeaddrinfo_all(hints.ai_family,la);
1466-
returnSTATUS_ERROR;/* we don't expect this to happen */
1463+
/* we don't expect this to happen */
1464+
ident_return= false;
1465+
gotoident_inet_done;
14671466
}
14681467

14691468
sock_fd=socket(ident_serv->ai_family,ident_serv->ai_socktype,
@@ -1554,8 +1553,10 @@ ident_inet(hbaPort *port)
15541553
ident_inet_done:
15551554
if (sock_fd!=PGINVALID_SOCKET)
15561555
closesocket(sock_fd);
1557-
pg_freeaddrinfo_all(remote_addr.addr.ss_family,ident_serv);
1558-
pg_freeaddrinfo_all(local_addr.addr.ss_family,la);
1556+
if (ident_serv)
1557+
pg_freeaddrinfo_all(remote_addr.addr.ss_family,ident_serv);
1558+
if (la)
1559+
pg_freeaddrinfo_all(local_addr.addr.ss_family,la);
15591560

15601561
if (ident_return)
15611562
/* Success! Check the usermap */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp