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

Commit918d74a

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 parent7016d97 commit918d74a

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
@@ -486,7 +486,6 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
486486
boolnulls[11];
487487
HeapTupletuple;
488488
PgBackendStatus*beentry;
489-
SockAddrzero_clientaddr;
490489

491490
MemSet(values,0,sizeof(values));
492491
MemSet(nulls,0,sizeof(nulls));
@@ -527,6 +526,8 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
527526
/* Values only available to same user or superuser */
528527
if (superuser()||beentry->st_userid==GetUserId())
529528
{
529+
SockAddrzero_clientaddr;
530+
530531
if (*(beentry->st_activity)=='\0')
531532
{
532533
values[4]=CStringGetTextDatum("<command string not enabled>");
@@ -556,7 +557,7 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
556557
/* A zeroed client addr means we don't know */
557558
memset(&zero_clientaddr,0,sizeof(zero_clientaddr));
558559
if (memcmp(&(beentry->st_clientaddr),&zero_clientaddr,
559-
sizeof(zero_clientaddr)==0))
560+
sizeof(zero_clientaddr))==0)
560561
{
561562
nulls[9]= true;
562563
nulls[10]= true;
@@ -809,7 +810,7 @@ pg_stat_get_backend_client_addr(PG_FUNCTION_ARGS)
809810
/* A zeroed client addr means we don't know */
810811
memset(&zero_clientaddr,0,sizeof(zero_clientaddr));
811812
if (memcmp(&(beentry->st_clientaddr),&zero_clientaddr,
812-
sizeof(zero_clientaddr)==0))
813+
sizeof(zero_clientaddr))==0)
813814
PG_RETURN_NULL();
814815

815816
switch (beentry->st_clientaddr.addr.ss_family)
@@ -856,7 +857,7 @@ pg_stat_get_backend_client_port(PG_FUNCTION_ARGS)
856857
/* A zeroed client addr means we don't know */
857858
memset(&zero_clientaddr,0,sizeof(zero_clientaddr));
858859
if (memcmp(&(beentry->st_clientaddr),&zero_clientaddr,
859-
sizeof(zero_clientaddr)==0))
860+
sizeof(zero_clientaddr))==0)
860861
PG_RETURN_NULL();
861862

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp