diff --git a/src/main.rs b/src/main.rs index ce66e97..f6c1411 100644 --- a/src/main.rs +++ b/src/main.rs @@ -126,7 +126,12 @@ fn main() -> Result<(), Box> { println!("Contact URI: {}", contact_uri); let token = match args.token { - Some(token) => token, + Some(token) => { + if token.as_bytes().len() >= MAX_BYTES_PER_TRANSACTION { + return Err("Token is too long".into()) + } + token + }, None => { Uuid::new_v4().to_string() } @@ -185,7 +190,7 @@ fn main() -> Result<(), Box> { // create file with token let token_accessrights = generate_file_access_rights(FileAccessRights::FREE as u8, 0x00, 0x00, 0x00)?; - desfire.create_file_standard(0x03, FileCommunication::PLAIN, token_accessrights, token.as_bytes().len() as u32)?; + desfire.create_file_standard(0x03, FileCommunication::PLAIN, token_accessrights, MAX_BYTES_PER_TRANSACTION as u32)?; // Max desfire.write_data(0x03, 0x00, token.as_bytes())?; println!("created token file");