Browse Source

More relax instruction data length check

febo 5 months ago
parent
commit
2f37967727

+ 1 - 1
p-token/src/processor/approve_checked.rs

@@ -7,7 +7,7 @@ use {
 #[inline(always)]
 pub fn process_approve_checked(accounts: &[AccountInfo], instruction_data: &[u8]) -> ProgramResult {
     // expected u64 (8) + u8 (1)
-    let (amount, decimals) = if instruction_data.len() == 9 {
+    let (amount, decimals) = if instruction_data.len() >= 9 {
         let (amount, decimals) = instruction_data.split_at(U64_BYTES);
         (
             // SAFETY: The size of `amount` is `U64_BYTES` bytes.

+ 1 - 1
p-token/src/processor/burn_checked.rs

@@ -7,7 +7,7 @@ use {
 #[inline(always)]
 pub fn process_burn_checked(accounts: &[AccountInfo], instruction_data: &[u8]) -> ProgramResult {
     // expected u64 (8) + u8 (1)
-    let (amount, decimals) = if instruction_data.len() == 9 {
+    let (amount, decimals) = if instruction_data.len() >= 9 {
         let (amount, decimals) = instruction_data.split_at(U64_BYTES);
         (
             // SAFETY: The size of `amount` is `U64_BYTES` bytes.

+ 1 - 1
p-token/src/processor/transfer_checked.rs

@@ -10,7 +10,7 @@ pub fn process_transfer_checked(
     instruction_data: &[u8],
 ) -> ProgramResult {
     // expected u64 (8) + u8 (1)
-    let (amount, decimals) = if instruction_data.len() == 9 {
+    let (amount, decimals) = if instruction_data.len() >= 9 {
         let (amount, decimals) = instruction_data.split_at(U64_BYTES);
         (
             // SAFETY: The size of `amount` is `U64_BYTES` bytes.