Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
programs/sbf: "fix" invalid_reference_casting lint
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrod committed Jan 9, 2024
1 parent 5c2d7b6 commit 2e0fe8f
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions programs/sbf/rust/spoof1/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ fn process_instruction(
let mut tmp_native_owner = [0u8; 32];
tmp_native_owner.copy_from_slice(accounts[0].owner.as_ref());

let owner_addr = accounts[0].owner as *const Pubkey;
unsafe {
std::ptr::write_volatile(owner_addr as *mut [u8; 32], fake_system.owner.to_bytes());
}
accounts[0].assign(fake_system.owner);

let system = &accounts[0];
let mut new_system = system.clone();
Expand All @@ -44,10 +41,7 @@ fn process_instruction(
msg!("swapped owner and data");
invoke(&ix, &[target.clone(), me.clone(), new_system])?;

let owner_addr = accounts[0].owner as *const Pubkey;
unsafe {
std::ptr::write_volatile(owner_addr as *mut [u8; 32], tmp_native_owner);
}
accounts[0].assign(&Pubkey::from(tmp_native_owner));

Ok(())
}

0 comments on commit 2e0fe8f

Please sign in to comment.