From b6fac8c5103633496796e5c989ee7eae72af0df3 Mon Sep 17 00:00:00 2001 From: Mats Kindahl Date: Thu, 31 Oct 2024 17:05:42 +0100 Subject: [PATCH] Verify that heap tuple is valid before using If the heap tuple fetched from the cache in `ts_bgw_job_validate_job_owner` is not valid, the error will print garbage for the role name, so check that the fetched tuple is valid before using it. --- src/bgw/job.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bgw/job.c b/src/bgw/job.c index 0eb993895e6..5414b6d823d 100644 --- a/src/bgw/job.c +++ b/src/bgw/job.c @@ -961,6 +961,10 @@ void ts_bgw_job_validate_job_owner(Oid owner) { HeapTuple role_tup = SearchSysCache1(AUTHOID, ObjectIdGetDatum(owner)); + + if (!HeapTupleIsValid(role_tup)) + elog(ERROR, "cache lookup failed for role %u", owner); + Form_pg_authid rform = (Form_pg_authid) GETSTRUCT(role_tup); if (!rform->rolcanlogin)