From edd6ae588a73a029a94504e4daba0c0e06e3803e Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 7 Jul 2021 19:02:52 +0000 Subject: [PATCH] Update verify policy (backport #18459) (#18491) * Update verify policy (#18459) (cherry picked from commit 44289e6728b293ff4f9be95eb0d6a381df008b5c) * resolve conflicts Co-authored-by: Jack May --- runtime/src/message_processor.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/runtime/src/message_processor.rs b/runtime/src/message_processor.rs index 84f021ff20..af8f956d86 100644 --- a/runtime/src/message_processor.rs +++ b/runtime/src/message_processor.rs @@ -173,7 +173,7 @@ impl PreAccount { } if !is_writable // line coverage used to get branch coverage || pre.executable() - || program_id != pre.owner() + || program_id != post.owner() { return Err(InstructionError::ExecutableModified); } @@ -1777,6 +1777,21 @@ mod tests { ); } + #[test] + fn test_verify_account_changes_owner_executable() { + let alice_program_id = solana_sdk::pubkey::new_rand(); + let bob_program_id = solana_sdk::pubkey::new_rand(); + + assert_eq!( + Change::new(&alice_program_id, &alice_program_id) + .owner(&bob_program_id) + .executable(false, true) + .verify(), + Err(InstructionError::ExecutableModified), + "Program should not be able to change owner and executable at the same time" + ); + } + #[test] fn test_process_message_readonly_handling() { #[derive(Serialize, Deserialize)]