Skip to content

Refactor cert store handling. - #42

Merged
copybara-service[bot] merged 1 commit into
masterfrom
test_407860877
Nov 9, 2021
Merged

copybara-service[bot] merged 1 commit into
masterfrom
test_407860877

Conversation

@copybara-service

@copybara-service copybara-service Bot commented Nov 5, 2021 •

Copy link
Copy Markdown

Refactor cert store handling.

With the previous behavior, the stores are closed immediately after any functions using them return. This is potentially problematic, as some functions return handles to the data that's inside the now closed store. It's counter-intuitive to the caller that certtostore may have already allowed Windows to release the store, despite the WinCertStore remaining open. Further, the store was closed with the CHECK_FLAG which allows any other handles associated with the store to leak if the caller doesn't clean them up.

The new behavior is to hold the any store handles open inside WinCertStore. These will be freed when the user calls Close() on the WinCertStore. Failure to do so will leak the handle, but this is arguably preferable to trapping the user into vague cases where handles may have been closed prematurely. It also allows the use of the FORCE_FLAG, which will help prevent leaking of associated handles as long as Close() is called.

@copybara-service copybara-service Bot changed the title Refactor user and system cert store handling Refactor cert store handling. Nov 5, 2021
With the previous behavior, the stores are closed immediately after any functions using them return. This is potentially problematic, as some functions return handles to the data that's inside the now closed store. It's counter-intuitive to the caller that certtostore may have already allowed Windows to release the store, despite the WinCertStore remaining open. Further, the store was closed with the CHECK_FLAG which allows any other handles associated with the store to leak if the caller doesn't clean them up.

The new behavior is to hold the any store handles open inside WinCertStore. These will be freed when the user calls Close() on the WinCertStore. Failure to do so will leak the handle, but this is arguably preferable to trapping the user into vague cases where handles may have been closed prematurely. It also allows the use of the FORCE_FLAG, which will help prevent leaking of associated handles as long as Close() is called.

PiperOrigin-RevId: 408645486
@copybara-service
copybara-service Bot merged commit d1c9527 into master Nov 9, 2021
@copybara-service
copybara-service Bot deleted the test_407860877 branch November 9, 2021 18:28
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.

0 participants