Skip to content

Commit

Permalink
Merge pull request #171 from brotskydotcom/rust-178
Browse files Browse the repository at this point in the history
Release v2.3.3 with fixes for issues introduced by rust 1.78.
  • Loading branch information
brotskydotcom authored May 2, 2024
2 parents 252f43c + e371b5c commit dc256b1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ keywords = ["password", "credential", "keychain", "keyring", "cross-platform"]
license = "MIT OR Apache-2.0"
name = "keyring"
repository = "https://github.com/hwchen/keyring-rs.git"
version = "2.3.2"
version = "2.3.3"
rust-version = "1.68"
edition = "2021"
exclude = [".github/"]
Expand Down
2 changes: 1 addition & 1 deletion src/keyutils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ impl KeyutilsCredential {

// Construct the credential with a URI-style description
let description = match target {
Some(value) if value.is_empty() => {
Some("") => {
return Err(ErrorCode::Invalid(
"target".to_string(),
"cannot be empty".to_string(),
Expand Down
6 changes: 6 additions & 0 deletions src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ fn extract_password(credential: &CREDENTIALW) -> Result<String> {
// get password blob
let blob_pointer: *const u8 = credential.CredentialBlob;
let blob_len: usize = credential.CredentialBlobSize as usize;
if blob_len == 0 {
return Ok(String::new());
}
let blob = unsafe { std::slice::from_raw_parts(blob_pointer, blob_len) };
// 3rd parties may write credential data with an odd number of bytes,
// so we make sure that we don't try to decode those as utf16
Expand Down Expand Up @@ -355,6 +358,9 @@ unsafe fn from_wstr(ws: *const u16) -> String {
}
// this code from https://stackoverflow.com/a/48587463/558006
let len = (0..).take_while(|&i| *ws.offset(i) != 0).count();
if len == 0 {
return String::new();
}
let slice = std::slice::from_raw_parts(ws, len);
String::from_utf16_lossy(slice)
}
Expand Down

0 comments on commit dc256b1

Please sign in to comment.