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

Commit150a30e

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 parent0c07ef1 commit150a30e

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
@@ -600,7 +600,6 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
600600
boolnulls[14];
601601
HeapTupletuple;
602602
PgBackendStatus*beentry;
603-
SockAddrzero_clientaddr;
604603

605604
MemSet(values,0,sizeof(values));
606605
MemSet(nulls,0,sizeof(nulls));
@@ -641,6 +640,8 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
641640
/* Values only available to same user or superuser */
642641
if (superuser()||beentry->st_userid==GetUserId())
643642
{
643+
SockAddrzero_clientaddr;
644+
644645
switch (beentry->st_state)
645646
{
646647
caseSTATE_IDLE:
@@ -692,7 +693,7 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
692693
/* A zeroed client addr means we don't know */
693694
memset(&zero_clientaddr,0,sizeof(zero_clientaddr));
694695
if (memcmp(&(beentry->st_clientaddr),&zero_clientaddr,
695-
sizeof(zero_clientaddr)==0))
696+
sizeof(zero_clientaddr))==0)
696697
{
697698
nulls[11]= true;
698699
nulls[12]= true;
@@ -956,7 +957,7 @@ pg_stat_get_backend_client_addr(PG_FUNCTION_ARGS)
956957
/* A zeroed client addr means we don't know */
957958
memset(&zero_clientaddr,0,sizeof(zero_clientaddr));
958959
if (memcmp(&(beentry->st_clientaddr),&zero_clientaddr,
959-
sizeof(zero_clientaddr)==0))
960+
sizeof(zero_clientaddr))==0)
960961
PG_RETURN_NULL();
961962

962963
switch (beentry->st_clientaddr.addr.ss_family)
@@ -1003,7 +1004,7 @@ pg_stat_get_backend_client_port(PG_FUNCTION_ARGS)
10031004
/* A zeroed client addr means we don't know */
10041005
memset(&zero_clientaddr,0,sizeof(zero_clientaddr));
10051006
if (memcmp(&(beentry->st_clientaddr),&zero_clientaddr,
1006-
sizeof(zero_clientaddr)==0))
1007+
sizeof(zero_clientaddr))==0)
10071008
PG_RETURN_NULL();
10081009

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp