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

Commit1f069d2

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 parent035226c commit1f069d2

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
@@ -587,7 +587,6 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
587587
boolnulls[12];
588588
HeapTupletuple;
589589
PgBackendStatus*beentry;
590-
SockAddrzero_clientaddr;
591590

592591
MemSet(values,0,sizeof(values));
593592
MemSet(nulls,0,sizeof(nulls));
@@ -628,6 +627,8 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
628627
/* Values only available to same user or superuser */
629628
if (superuser()||beentry->st_userid==GetUserId())
630629
{
630+
SockAddrzero_clientaddr;
631+
631632
if (*(beentry->st_activity)=='\0')
632633
{
633634
values[4]=CStringGetTextDatum("<command string not enabled>");
@@ -657,7 +658,7 @@ pg_stat_get_activity(PG_FUNCTION_ARGS)
657658
/* A zeroed client addr means we don't know */
658659
memset(&zero_clientaddr,0,sizeof(zero_clientaddr));
659660
if (memcmp(&(beentry->st_clientaddr),&zero_clientaddr,
660-
sizeof(zero_clientaddr)==0))
661+
sizeof(zero_clientaddr))==0)
661662
{
662663
nulls[9]= true;
663664
nulls[10]= true;
@@ -919,7 +920,7 @@ pg_stat_get_backend_client_addr(PG_FUNCTION_ARGS)
919920
/* A zeroed client addr means we don't know */
920921
memset(&zero_clientaddr,0,sizeof(zero_clientaddr));
921922
if (memcmp(&(beentry->st_clientaddr),&zero_clientaddr,
922-
sizeof(zero_clientaddr)==0))
923+
sizeof(zero_clientaddr))==0)
923924
PG_RETURN_NULL();
924925

925926
switch (beentry->st_clientaddr.addr.ss_family)
@@ -966,7 +967,7 @@ pg_stat_get_backend_client_port(PG_FUNCTION_ARGS)
966967
/* A zeroed client addr means we don't know */
967968
memset(&zero_clientaddr,0,sizeof(zero_clientaddr));
968969
if (memcmp(&(beentry->st_clientaddr),&zero_clientaddr,
969-
sizeof(zero_clientaddr)==0))
970+
sizeof(zero_clientaddr))==0)
970971
PG_RETURN_NULL();
971972

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp