postgres.git / summary / log / commit / refs

commit    511449d40fd48ba97556a03c272fd66b9c2c3f9c
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Thu Sep 23 20:53:42 2010 +0000
First released in: 9.1.0, 7.4.30, 8.0.26, 8.1.22, 8.2.18, 8.3.12, 8.4.5, 9.0.1

    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(+) diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c index 4ec57e11d33..206a1d1898a 100644 --- a/src/backend/commands/variable.c +++ b/src/backend/commands/variable.c @@ -680,6 +680,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')); [parent: 4e2e9f27dd15]