-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weird bug with hex conversions on macOS #4
Comments
I’m using the following diff in my fork, and that seems to have resolved my problems for now: if output.status.success() { if output.status.success() {
let output_string = String::from_utf8(output.stdout).unwrap().trim().to_owned(); let output_string = String::from_utf8(output.stdout).unwrap().trim().to_owned();
// padded with extra 'ffffff' before each octet?
+ Ok(output_string)
- //println!("{:?}", output_string);
- match output_string.from_hex() {
- Ok(bytes) => {
- // filter out extra 255?
- let bytes: Vec<_> = bytes.into_iter().filter(|&b| b != 255).collect();
- Ok(String::from_utf8(bytes).expect("error converting hex to utf8"))
- },
- _ => Ok(output_string),
- }
} else {
Err(KeyringError::MacOsKeychainError)
} |
Hi, Thanks for the report! I'm in the process of procuring a mac to help finish up development on this library. I should be able to push a fix to crates.io by the end of the week, hope you can make do for now. I need to go back and verify the behavior of http://stackoverflow.com/questions/22370552/keychain-services-secure-notes and see if I just made a dumb mistake in the original implementation. After that, I'm going to finish up my plans for this lib:
|
Closed by #6. Now handles utf8 passwords (including "special chars) on osx correctly. Version is bumped to 0.2 |
I have a weird bug where certain strings cause keyring-rs to throw an error on macOS. I haven’t worked out exactly what’s causing it, but it looks like my keychain entries are being interpreted as hex, and that’s throwing it off.
If I create a keychain entry
("testing", "password", "aa")
, put the following inmain.rs
and then callcargo run
:I get the following error:
Other strings that produce the error:
bb
,c1
,99
,90
,80
.I get the correct result with
7f
.If I try hex strings below
7f
(e.g.6a
,00
,0a
), the program exits correctly but the item it retrieves from the keychain is incorrect. e.g. if the keychain entry is6a
, it printsOk("j")
.Versions:
The text was updated successfully, but these errors were encountered: