Repository navigation
fix(ffi): make AlgorithmIdentifier, Extension and AuthenticodeSignature disposable again - #541
Draft
irvingouj@Devolutions (irvingoujAtDevolution) wants to merge 1 commit into
Conversation
irvingouj@Devolutions (irvingoujAtDevolution)
added this pull request to stack #540
September 30, 2026 03:01
This was referenced Sep 30, 2026
irvingouj@Devolutions (irvingoujAtDevolution)
force-pushed
the
ffi/dotnet-restore-disposable
branch
from
October 8, 2026 00:10
b547241 to
91cd751
Compare
…re disposable again These three lost IDisposable in the devo.2 migration because each one handed out a view that borrowed from it, and Diplomat won't let a manually disposable type keep a borrow alive. The views now own a clone instead of borrowing: - AlgorithmIdentifierParameters holds its own parameters - ExtensionView holds its own Extension - AuthenticodeValidator holds its own signature and records each setter call as a step, then builds picky's borrowing validator inside verify() That also fixes a use-after-free. The old validator kept a &UtcDate that C# only leased for the setter call, so disposing the date before Verify() read freed memory. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
irvingouj@Devolutions (irvingoujAtDevolution)
force-pushed
the
ffi/dotnet-restore-disposable
branch
from
October 13, 2026 12:58
91cd751 to
f860c60
Compare
irvingouj@Devolutions (irvingoujAtDevolution)
removed this pull request from stack #540
October 13, 2026 13:02
irvingouj@Devolutions (irvingoujAtDevolution)
added this pull request to stack #562
October 13, 2026 13:02
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On top of #539. Puts
IDisposableback on the 3 types #536 had to drop it from.AlgorithmIdentifier,ExtensionandAuthenticodeSignatureeach handed out a view that borrowed from them, and devo.2 won't let a disposable type keep a borrow alive. Now the views own a clone instead:AlgorithmIdentifierParametersholds its own parametersExtensionViewholds its ownExtensionAuthenticodeValidatorholds its own signature and records each setter call as a step, then builds picky's validator insideVerify()&UtcDatethat C# only held for the setter call, so disposing the date beforeVerify()read freed memoryNew tests in
Pkcs7Tests: the 3 types areIDisposable, a validator still verifies after its signature, hash and date are disposed (and rejects an out-of-range date), and parameters outlive theirAlgorithmIdentifier.Tested: 32/32 on net8.0, debug and release native.