Inaccessible Registry Keys Throw Unhandled SecurityException#49
Open
sapph42 wants to merge 2 commits intorodneyviana:masterfrom
Open
Inaccessible Registry Keys Throw Unhandled SecurityException#49sapph42 wants to merge 2 commits intorodneyviana:masterfrom
sapph42 wants to merge 2 commits intorodneyviana:masterfrom
Conversation
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.
If other users on the computer have OneDrive enabled, and the user context running does not have access to every key in HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SyncRootManager, then OdSyncStatusWS.GetStatusInternal() will throw an unhandled SecurityException.
I have moved the declaration of detail higher in the method, wrapped the dangerous code in a try/catch (with a couple reinits of detail to account for it not being redeclared in every loop), and set detail to a default StatusDetail() if exception is caught. The yield return is moved out of try/catch.
This leads, however, to API.GetStateBySyncRootId potentially being passed a null SyncRootId and throwing an invalid memory access error. I have prevented this in two ways: GetStatusBySyncRootId now has a null check that immediately returns 1. Addtionally, OdSyncStatusWS.GetStatus now checks for a null SyncRootId before calling GetStateBySyncRootId.