From 1e4a7c41102288955b290926b51c556fe8cb7daa Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 23 Sep 2010 16:53:53 -0400 Subject: Prevent show_session_authorization from crashing when session_authorization 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. --- src/backend/commands/variable.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/backend/commands/variable.c') diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c index 4076312799d..ff68381d79a 100644 --- a/src/backend/commands/variable.c +++ b/src/backend/commands/variable.c @@ -830,6 +830,10 @@ show_session_authorization(void) AclId savedsysid; 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')); -- cgit v1.2.3