Skip to content

Commit e9ef376

Browse files
authored
Fix for hijack attack of candy machine (#1366)
1 parent 4f835f7 commit e9ef376

File tree

1 file changed

+2
-2
lines changed
  • rust/nft-candy-machine-v2/src

1 file changed

+2
-2
lines changed

rust/nft-candy-machine-v2/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ fn get_space_for_candy(data: CandyMachineData) -> core::result::Result<usize, Pr
611611
#[derive(Accounts)]
612612
#[instruction(data: CandyMachineData)]
613613
pub struct InitializeCandyMachine<'info> {
614-
#[account(mut, constraint= candy_machine.to_account_info().owner == program_id && candy_machine.to_account_info().data_len() >= get_space_for_candy(data)?)]
614+
#[account(zero, constraint= candy_machine.to_account_info().owner == program_id && candy_machine.to_account_info().data_len() >= get_space_for_candy(data)?)]
615615
candy_machine: UncheckedAccount<'info>,
616616
wallet: UncheckedAccount<'info>,
617617
authority: UncheckedAccount<'info>,
@@ -841,7 +841,7 @@ pub fn get_good_index(
841841
.checked_rem(8)
842842
.ok_or(ErrorCode::NumericalOverflowError)?;
843843
let reversed = 8 - eight_remainder + 1;
844-
if (eight_remainder != 0 && pos) || (reversed != 0 && !pos) {
844+
if (eight_remainder != 0 && pos) || (reversed != 0 && !pos) {
845845
//msg!("Moving by {}", eight_remainder);
846846
if pos {
847847
index_to_use += eight_remainder;

0 commit comments

Comments
 (0)