Skip to content

Fix getting and setting credentials from Windows - #7

Open
hawkeye116477 wants to merge 2 commits into
sillsdev:masterfrom
hawkeye116477:master
Open

Fix getting and setting credentials from Windows#7
hawkeye116477 wants to merge 2 commits into
sillsdev:masterfrom
hawkeye116477:master

Conversation

@hawkeye116477

@hawkeye116477 hawkeye116477 commented Aug 8, 2026

Copy link
Copy Markdown

Sometimes it could read too much if no null sign specified at the end, so exact length to read is needed.

return credential?.CredentialBlobSize == 0
? null
: Marshal.PtrToStringUni(credential?.CredentialBlob ?? IntPtr.Zero);
: Marshal.PtrToStringUni(credential?.CredentialBlob ?? IntPtr.Zero, (int)(credential?.CredentialBlobSize ?? 0) / 2).TrimEnd('\0');

@ermshiperete ermshiperete Aug 10, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a unit test that demonstrates the need for this change?

Also, why divide by 2, and trim the null character at the end?

@hawkeye116477 hawkeye116477 Aug 10, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added trimming null character, cuz Sil when setting password for some reason always added it, while that shouldn't happen (#8 fixes that case).
Dividing by 2 is needed, cuz we need amount of characters to read and each character takes up 2 bytes.

I done that change, cuz had problem with getting some values by Sil set from python's keyring.
So earlier implementation in some cases would require adding null character at the end to read correctly, which I think shouldn't be done, at least didn't saw that at other implementations.

@hawkeye116477 hawkeye116477 changed the title Fix getting credential from Windows Fix getting and setting credentials from Windows Aug 11, 2026
ermshiperete added a commit to ermshiperete/SIL.PasswordStore that referenced this pull request Aug 13, 2026
Using passwords with non-latin characters sometimes failed.

Supersedes: sillsdev#7
ermshiperete added a commit that referenced this pull request Aug 13, 2026
Using passwords with non-latin characters sometimes failed.

Co-authored-by: hawkeye116477 <hawkeye116477@gmail.com>
Supersedes: #7
ermshiperete added a commit that referenced this pull request Aug 14, 2026
Using passwords with non-latin characters sometimes failed.

Co-authored-by: hawkeye116477 <hawkeye116477@gmail.com>
Supersedes: #7
ermshiperete added a commit that referenced this pull request Aug 14, 2026
Using passwords with non-latin characters sometimes failed.

Co-authored-by: hawkeye116477 <hawkeye116477@gmail.com>
Supersedes: #7
ermshiperete added a commit that referenced this pull request Aug 14, 2026
Using passwords with non-latin characters sometimes failed.

Co-authored-by: hawkeye116477 <hawkeye116477@gmail.com>
Supersedes: #7
ermshiperete added a commit that referenced this pull request Aug 14, 2026
Using passwords with non-latin characters sometimes failed.

Co-authored-by: hawkeye116477 <hawkeye116477@gmail.com>
Supersedes: #7
ermshiperete added a commit that referenced this pull request Aug 18, 2026
Using passwords with non-latin characters sometimes failed.

Co-authored-by: hawkeye116477 <hawkeye116477@gmail.com>
Supersedes: #7
ermshiperete added a commit that referenced this pull request Aug 19, 2026
Using passwords with non-latin characters sometimes failed.

Co-authored-by: hawkeye116477 <hawkeye116477@gmail.com>
Supersedes: #7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants