Skip to content

Commit dc256b1

Browse files
Merge pull request #171 from brotskydotcom/rust-178
Release v2.3.3 with fixes for issues introduced by rust 1.78.
2 parents 252f43c + e371b5c commit dc256b1

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ keywords = ["password", "credential", "keychain", "keyring", "cross-platform"]
66
license = "MIT OR Apache-2.0"
77
name = "keyring"
88
repository = "https://github.com/hwchen/keyring-rs.git"
9-
version = "2.3.2"
9+
version = "2.3.3"
1010
rust-version = "1.68"
1111
edition = "2021"
1212
exclude = [".github/"]

src/keyutils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl KeyutilsCredential {
241241

242242
// Construct the credential with a URI-style description
243243
let description = match target {
244-
Some(value) if value.is_empty() => {
244+
Some("") => {
245245
return Err(ErrorCode::Invalid(
246246
"target".to_string(),
247247
"cannot be empty".to_string(),

src/windows.rs

+6
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,9 @@ fn extract_password(credential: &CREDENTIALW) -> Result<String> {
326326
// get password blob
327327
let blob_pointer: *const u8 = credential.CredentialBlob;
328328
let blob_len: usize = credential.CredentialBlobSize as usize;
329+
if blob_len == 0 {
330+
return Ok(String::new());
331+
}
329332
let blob = unsafe { std::slice::from_raw_parts(blob_pointer, blob_len) };
330333
// 3rd parties may write credential data with an odd number of bytes,
331334
// so we make sure that we don't try to decode those as utf16
@@ -355,6 +358,9 @@ unsafe fn from_wstr(ws: *const u16) -> String {
355358
}
356359
// this code from https://stackoverflow.com/a/48587463/558006
357360
let len = (0..).take_while(|&i| *ws.offset(i) != 0).count();
361+
if len == 0 {
362+
return String::new();
363+
}
358364
let slice = std::slice::from_raw_parts(ws, len);
359365
String::from_utf16_lossy(slice)
360366
}

0 commit comments

Comments
 (0)