Skip to content

Commit

Permalink
Merge pull request #102 from Nitrokey/quickfixes
Browse files Browse the repository at this point in the history
Quickfixes
  • Loading branch information
szszszsz authored Aug 19, 2023
2 parents 3494725 + fab1fff commit 7203ade
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
9 changes: 7 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
.PHONY: ci setup-ubuntu
.PHONY: ci setup-ubuntu run

FLAGS=--example usbip --features "ctaphid devel"

ci:
cargo test --verbose
cargo build --example usbip --features "ctaphid devel"
cargo build $(FLAGS)

run:
env RUST_LOG=debug cargo run $(FLAGS)

setup-ubuntu:
sudo apt install llvm libclang-dev make
2 changes: 1 addition & 1 deletion examples/usbip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ impl trussed_usbip::Apps<'static, VirtClient, dispatch::Dispatch> for Apps {
data.encode(),
);
let options = secrets_app::Options::new(
Location::Internal,
Location::External,
CustomStatus::ReverseHotpSuccess as u8,
CustomStatus::ReverseHotpError as u8,
[0x42, 0x42, 0x42, 0x42],
Expand Down
12 changes: 8 additions & 4 deletions src/authenticator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,9 @@ where
}

// Abort if the credentials count limit is reached
if self.count_credentials()? >= self.options.max_resident_credentials_allowed {
let _current_count = self.count_credentials()?;
if _current_count >= self.options.max_resident_credentials_allowed {
warn_now!("Credentials limit hit: {:?}", _current_count,);
return Err(Status::NotEnoughMemory);
}

Expand All @@ -615,9 +617,11 @@ where
// Explicitly disallow to overwrite existing credentials by default
self.err_if_credential_with_label_exists(register.credential.label)?;

// 1. Replace secret in credential with handle
let credential =
CredentialFlat::try_from(&register.credential).map_err(|_| Status::NotEnoughMemory)?;
// 1. Replace secret in credential with a handle
let credential = CredentialFlat::try_from(&register.credential).map_err(|_e| {
warn_now!("Failed to convert credential to flat: {:?}", _e);
Status::NotEnoughMemory
})?;

// 2. Generate a filename for the credential
let filename = self.filename_for_label(&credential.label);
Expand Down
4 changes: 2 additions & 2 deletions src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ impl State {
})?;
debug_now!("Container size: {}", data_serialized.len());
try_syscall!(trussed.write_file(self.location, filename, data_serialized, None)).map_err(
|_| {
debug_now!("Failed to write the file");
|_e| {
warn_now!("Failed to write the file: {:?}", _e);
Status::NotEnoughMemory
},
)?;
Expand Down

0 comments on commit 7203ade

Please sign in to comment.