git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ee63981)
Prevent show_session_authorization from crashing when session_authorization
2010年9月23日 20:53:16 +0000 (16:53 -0400)
2010年9月23日 20:53:16 +0000 (16:53 -0400)
hasn't been set.

The only known case where this can happen is when show_session_authorization
is invoked in an autovacuum process, which is possible if an index function
calls it, as for example in bug #5669 from Andrew Geery. We could perhaps
try to return a sensible value, such as the name of the cluster-owning
superuser; but that seems like much more trouble than the case is worth,
and in any case it could create new possible failure modes. Simply
returning an empty string seems like the most appropriate fix.

Back-patch to all supported versions, even those before autovacuum, just
in case there's another way to provoke this crash.


diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c
index 219ceba7ce54124b703d38fc848a3ff5b502ccc5..bbeb50f332a67f7274041ccb4a065da47f9f4d3b 100644 (file)
--- a/src/backend/commands/variable.c
+++ b/src/backend/commands/variable.c
@@ -771,6 +771,10 @@ show_session_authorization(void)
Oid savedoid;
char *endptr;
+ /* If session_authorization hasn't been set in this process, return "" */
+ if (value == NULL || value[0] == '0円')
+ return "";
+
Assert(strspn(value, "x") == NAMEDATALEN &&
(value[NAMEDATALEN] == 'T' || value[NAMEDATALEN] == 'F'));
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /