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

Commita133bf7

Browse files
committed
Fix misplaced right paren bugs in pgstatfuncs.c.
The bug would only show up if the C sockaddr structure containedzero in the first byte for a valid address; otherwise it wouldfail to fail, which is probably why it went unnoticed for so long.Patch submitted by Joel Jacobson after seeing an article by AndreyKarpov in which he reports finding this through static codeanalysis using PVS-Studio. While I was at it I moved a definitionof a local variable referenced in the buggy code to a more localcontext.Backpatch to all supported branches.
1 parenta09e3fd commita133bf7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

‎src/backend/utils/adt/pgstatfuncs.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,6 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
618618
boolnulls[14];
619619
HeapTupletuple;
620620
PgBackendStatus*beentry;
621-
SockAddrzero_clientaddr;
622621

623622
MemSet(values,0,sizeof(values));
624623
MemSet(nulls,0,sizeof(nulls));
@@ -659,6 +658,8 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
659658
/* Values only available to same user or superuser */
660659
if (superuser()||beentry->st_userid==GetUserId())
661660
{
661+
SockAddrzero_clientaddr;
662+
662663
switch (beentry->st_state)
663664
{
664665
caseSTATE_IDLE:
@@ -710,7 +711,7 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
710711
/* A zeroed client addr means we don't know */
711712
memset(&zero_clientaddr,0,sizeof(zero_clientaddr));
712713
if (memcmp(&(beentry->st_clientaddr),&zero_clientaddr,
713-
sizeof(zero_clientaddr)==0))
714+
sizeof(zero_clientaddr))==0)
714715
{
715716
nulls[11]= true;
716717
nulls[12]= true;
@@ -974,7 +975,7 @@ pg_stat_get_backend_client_addr(PG_FUNCTION_ARGS)
974975
/* A zeroed client addr means we don't know */
975976
memset(&zero_clientaddr,0,sizeof(zero_clientaddr));
976977
if (memcmp(&(beentry->st_clientaddr),&zero_clientaddr,
977-
sizeof(zero_clientaddr)==0))
978+
sizeof(zero_clientaddr))==0)
978979
PG_RETURN_NULL();
979980

980981
switch (beentry->st_clientaddr.addr.ss_family)
@@ -1021,7 +1022,7 @@ pg_stat_get_backend_client_port(PG_FUNCTION_ARGS)
10211022
/* A zeroed client addr means we don't know */
10221023
memset(&zero_clientaddr,0,sizeof(zero_clientaddr));
10231024
if (memcmp(&(beentry->st_clientaddr),&zero_clientaddr,
1024-
sizeof(zero_clientaddr)==0))
1025+
sizeof(zero_clientaddr))==0)
10251026
PG_RETURN_NULL();
10261027

10271028
switch (beentry->st_clientaddr.addr.ss_family)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp