-
Notifications
You must be signed in to change notification settings - Fork 156
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
Add conditional check for TryGetPortablePdbMetadataReader
when PDB file is missing
#1001
Merged
lukaskohl-msft
merged 2 commits into
microsoft:users/lukaskohl/pdblocation-invalid
from
lukaskohl-msft:fix/pdbLocation-invalid
Aug 7, 2024
Merged
Add conditional check for TryGetPortablePdbMetadataReader
when PDB file is missing
#1001
lukaskohl-msft
merged 2 commits into
microsoft:users/lukaskohl/pdblocation-invalid
from
lukaskohl-msft:fix/pdbLocation-invalid
Aug 7, 2024
Conversation
This file contains 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
File.OpenRead can throw if pdb.PdbLocation is a directory. This can happen if (for some reason) the pdb file is not found. In which case PdbLocation will return the working directory, causing File.OpenRead to throw.
lukaskohl-msft
force-pushed
the
fix/pdbLocation-invalid
branch
from
August 5, 2024 12:18
66af743
to
81e1bc9
Compare
lukaskohl-msft
changed the title
Add conditional check for
Add conditional check for Aug 5, 2024
FromPortablePdbStream
inside PortableExecutable/PE.cs
TryGetPortablePdbMetadataReader
when PDB file is missing
@@ -16,6 +16,7 @@ | |||
- NEW => new feature | |||
|
|||
## UNRELEASED | |||
* BUG: Fix `TryGetPortablePdbMetadataReader` unexpectedly causes `UnauthorizedAccessException` error when the PDB file is missing. [1001](https://github.com/microsoft/binskim/pull/1001). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -16,6 +16,7 @@ | |||
- NEW => new feature | |||
|
|||
## UNRELEASED | |||
* BUG: Fix `TryGetPortablePdbMetadataReader` unexpectedly causes `UnauthorizedAccessException` error when the PDB file is missing. [1001](https://github.com/microsoft/binskim/pull/1001). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
michaelcfanning
approved these changes
Aug 5, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adds a sample library that has been compiled as a standalone portable executable. The library doesn't have an accompanying pdb file, where prior to commit `81e1bc93` would make binskim throw on the working thread.
lukaskohl-msft
changed the base branch from
main
to
users/lukaskohl/pdblocation-invalid
August 7, 2024 09:27
lukaskohl-msft
merged commit Aug 7, 2024
b839fdd
into
microsoft:users/lukaskohl/pdblocation-invalid
3 of 4 checks passed
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.
File.OpenRead
can throw ifpdb.PdbLocation
is a directory.This can happen if (for some reason) the pdb file is not found -- In which case
PdbLocation
will return the working directory, causingFile.OpenRead
to throw.There's perhaps a better place to put this check, or a better way to handle this. Suggestions welcome :)
It would be great to have this scenario logged in some way, as there are
E_PDB_NOT_FOUND
orE_PDB_DBG_NOT_FOUND
HRESULT codes.For example:
C:\somePath\sni.dll : error ERR997.ExceptionLoadingPdb : 'sni.dll' was not evaluated because its PDB could not be loaded (E_PDB_NOT_FOUND).
However, I was unable to find a good way to integrate that into existing functionality, let me know if that's easily implementable.