Check that the program was granted access to program_id (bp #13890) (#13892)

* Check that the program was granted access to program_id (#13890)

(cherry picked from commit 733fcbaa6c)

# Conflicts:
#	programs/bpf/tests/programs.rs

* Resolve conflicts

* nudge

* nudge

Co-authored-by: Jack May <jack@solana.com>
This commit is contained in:
mergify[bot]
2020-12-01 18:42:34 +00:00
committed by GitHub
parent 3318772bfe
commit f1265b544c
9 changed files with 3548 additions and 9 deletions

View File

@@ -1036,6 +1036,20 @@ fn verify_instruction<'a>(
}
}
// validate the caller has access to the program account
let _ = callers_keyed_accounts
.iter()
.find_map(|keyed_account| {
if &instruction.program_id == keyed_account.unsigned_key() {
Some(keyed_account)
} else {
None
}
})
.ok_or(SyscallError::InstructionError(
InstructionError::MissingAccount,
))?;
Ok(())
}