Skip to content

Commit

Permalink
Verify that heap tuple is valid before using
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mkindahl committed Nov 10, 2024
1 parent e5e9496 commit b6fac8c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/bgw/job.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b6fac8c

Please sign in to comment.