Skip to content

Commit

Permalink
Merge pull request #33 from ssp-rs/fixup/encrypted
Browse files Browse the repository at this point in the history
fixup: encrypted message data length check
  • Loading branch information
ssp-rs authored Oct 12, 2023
2 parents 34c3a8c + 5b4cb45 commit 078c5e9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ssp"
version = "0.5.2"
version = "0.5.3"
edition = "2021"
authors = ["SSP Rust Developers"]
description = "Messages and related types for implementing the SSP/eSSP serial communication protocol"
Expand Down
5 changes: 3 additions & 2 deletions src/encrypted/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ use crate::seed;

use crate::{
impl_default, impl_encrypted_message_ops, impl_message_from_buf, impl_response_display,
impl_response_ops, len, AesKey, Error, MessageOps, ResponseOps, Result, SequenceCount,
impl_response_ops, len, std::cmp, AesKey, Error, MessageOps, ResponseOps, Result,
SequenceCount,
};

use super::{encrypted_index as index, WrappedEncryptedMessage};
Expand Down Expand Up @@ -175,7 +176,7 @@ impl EncryptedResponse {
}

fn encrypt_data(&mut self) -> &mut [u8] {
let len = self.len();
let len = cmp::min(self.len(), len::MAX_ENCRYPTED_DATA);
self.buf[index::LEN..len].as_mut()
}

Expand Down
3 changes: 1 addition & 2 deletions src/payout_by_denomination/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,7 @@ impl fmt::Display for PayoutByDenominationCommand {
write!(
f,
"Payout denominations: {} | ",
self.payout_denominations()
.unwrap_or(PayoutDenominationList::new())
self.payout_denominations().unwrap_or_default()
)?;
write!(f, "Payout option: {} | ", self.payout_option())?;
write!(f, "CRC-16: 0x{:04x}", self.checksum())
Expand Down

0 comments on commit 078c5e9

Please sign in to comment.