Blacklist System.Windows.Forms form loaded to prevent a crash#6822
Merged
TravisEz13 merged 7 commits intoPowerShell:masterfrom May 7, 2018
Merged
Blacklist System.Windows.Forms form loaded to prevent a crash#6822TravisEz13 merged 7 commits intoPowerShell:masterfrom
TravisEz13 merged 7 commits intoPowerShell:masterfrom
Conversation
iSazonov
reviewed
May 5, 2018
| $ErrorId | ||
| ) | ||
|
|
||
| {[System.Reflection.Assembly]::Load('system.windows.forms')} | Should -Throw -ErrorId $ErrorId |
Collaborator
There was a problem hiding this comment.
Typo - should be Load($Name)
adityapatwardhan
requested changes
May 7, 2018
| @@ -0,0 +1,33 @@ | |||
| # Copyright (c) Microsoft Corporation. All rights reserved. | |||
| # Licensed under the MIT License. | |||
| Describe "Assembly.Load Validation Test" -Tags "CI" { | |||
Member
There was a problem hiding this comment.
Please add empty line after copyright comment.
| $ErrorId | ||
| ) | ||
|
|
||
| {[System.Reflection.Assembly]::Load($Name)} | Should -Throw -ErrorId $ErrorId |
Member
There was a problem hiding this comment.
Assembly.Load will not work if the assembly name is not a long form name. LoadWithPartialName should be used here instead. Or the name used should be System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Member
There was a problem hiding this comment.
Assembly.Load seems working with short name too:
PS:1> [System.Reflection.Assembly]::Load("System.Management.Automation")
GAC Version Location
--- ------- --------
False v4.0.30319 F:\pscore\System.Management.Automation.dll`
daxian-dbw
approved these changes
May 7, 2018
Member
|
LGTM, but please address the pending comments. |
adityapatwardhan
approved these changes
May 7, 2018
5 tasks
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.
PR Summary
Blacklist
System.Windows.Forms(WinForms) from being loaded to prevent a crashBefore the change
WinForms would load but


System.Drawingwould not when you actually tried to display a form.Then when the form was disposed the process would crash with a
TypeLoadException. Here are details from the crash dump:After this change, we refuse to load WinForms preventing the crash:

PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.[feature]if the change is significant or affects feature tests