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

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

(cherry picked from commit 733fcbaa6c)

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

* Resolve conflicts

Co-authored-by: Jack May <jack@solana.com>
This commit is contained in:
mergify[bot]
2020-12-01 17:49:17 +00:00
committed by GitHub
parent 446e02bad1
commit 01d9062f7b
9 changed files with 3544 additions and 5 deletions

View File

@@ -1156,6 +1156,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(())
}