Skip to content

Commit

Permalink
Verify that heap tuple is valid before using
Browse files Browse the repository at this point in the history
In `ts_bgw_job_validate_job_owner` a heap tuple is fetched but it is
not verified that it is valid. If the heap tuple is later used it can
cause a crash at best, or leak information from random memory at worst.

Fixed this by adding a check that the tuple is valid before trying to
use it.
  • Loading branch information
mkindahl committed Nov 11, 2024
1 parent 43e1bdb commit 7725448
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions .unreleased/pr_7432
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes: #7432 Verify that heap tuple is valid before using
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 7725448

Please sign in to comment.