Repository navigation
Improve error handling for cab extraction and limit module name to 128 characters - #28212
Closed
Aditya Patwardhan (adityapatwardhan) wants to merge 1 commit into
Closed
Aditya Patwardhan (adityapatwardhan) wants to merge 1 commit into
Aditya Patwardhan (adityapatwardhan) wants to merge 1 commit into
Conversation
Aditya Patwardhan (adityapatwardhan)
requested review from
a team and
Dongbo Wang (daxian-dbw)
as code owners
October 14, 2026 22:55
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Regression coverage is needed for the module-name boundary and CAB extraction failure paths.
2 open findings
What changed in this PR
This PR hardens PowerShell’s Updatable Help processing against CAB extraction failures and oversized module names.
Changes:
- Improves native callback error handling and file-handle validation.
- Rejects empty/root CAB entry paths and multi-cabinet continuation.
- Enforces a 128-character module-name limit with a resource-backed error message.
| File | Description |
|---|---|
| src/System.Management.Automation/resources/HelpDisplayStrings.resx | Adds the oversized module-name error message. |
| src/System.Management.Automation/help/UpdatableHelpModuleInfo.cs | Defines the module-name length limit. |
| src/System.Management.Automation/help/UpdatableHelpCommandBase.cs | Rejects oversized module names during help discovery. |
| src/System.Management.Automation/help/CabinetNativeApi.cs | Strengthens extraction validation and failure handling. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+486
to
+488
| if (closeResult != 0) | ||
| { | ||
| return IntPtr.Zero; |
| return; | ||
| } | ||
|
|
||
| if (module.Name.Length > UpdatableHelpModuleInfo.MaxModuleNameLength) |
Collaborator
|
Dup #28203 |
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
This pull request improves the robustness and security of the Cabinet extraction and Updatable Help code in PowerShell. The changes focus on better error handling for file operations, stricter validation of CAB entry paths, and defensive checks on module names to prevent issues with excessively long file paths.
Error handling and robustness improvements:
UnauthorizedAccessException,ArgumentException,NotSupportedException,SecurityException) inFdiOpento ensure that no exceptions escape into native code; instead, a failure is signaled with a return value, matching the existingIOExceptionhandling.FdiCloseto handle invalid pointers and catchIOException, returning error codes instead of throwing exceptions.FdiCloseand aborts extraction if closing the file fails, preventing corrupt or truncated files from being reported as successfully extracted.CreateFile, ensuring thatINVALID_HANDLE_VALUEis properly recognized as a failure.FdintNEXT_CABINETnotification, returning an error code since only single-cabinet updates are supported.Security and validation enhancements:
Defensive checks and user feedback:
MaxModuleNameLength = 128) to prevent excessively long module names from causing path or file name issues.ProcessSingleModuleObjectto reject modules with names exceeding the maximum length, with a localized error message in the resource file. [1] [2]PR Context
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright header