[PR #8712] Initialize stack variables. check return code from shell lnk loading #27276

Open
opened 2026-01-31 09:21:00 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/8712

State: closed
Merged: Yes


References

  • Commit f273aa679d4d9fb516678fc7ed5fc6495a8e8532 from os repository.

PR Checklist

Detailed Description of the Pull Request / Additional comments

  • We found and fixed this in November 2017, but I fumbled the replication and accidentally overwrote the commit. This digs it up from history and puts it back in our code.
  • When the shortcut file cannot be read for whatever reason, we are setting the hotkey value to uninitialized data as we never initialize several members on the stack in this function. It just so happens that the one in the dwHotkey field is commonly 0x4c or the letter L which is then sent into the window procedure to tell the OS to capture it as a global hotkey and foreground the conhost.exe that was started. We should realize the load failure and not set any hotkey at all and we should initialize the stack variables. This does both.

Validation Steps Performed

  • Manual scenario running LNK file that cannot be loaded from customer report (make LNK to cmd.exe, make it inaccessible to conhost so it can't load/read it.)
  • Manual scenario with mklink'd link that makes the shortcut parser attempt to load (and fail because it isn't a LNK at all from #7650)
**Original Pull Request:** https://github.com/microsoft/terminal/pull/8712 **State:** closed **Merged:** Yes --- ## References * Commit f273aa679d4d9fb516678fc7ed5fc6495a8e8532 from os repository. ## PR Checklist * [x] Closes #7650 * [x] I work here. * [x] Tests passed ## Detailed Description of the Pull Request / Additional comments * We found and fixed this in November 2017, but I fumbled the replication and accidentally overwrote the commit. This digs it up from history and puts it back in our code. * When the shortcut file cannot be read for whatever reason, we are setting the hotkey value to uninitialized data as we never initialize several members on the stack in this function. It just so happens that the one in the `dwHotkey` field is commonly `0x4c` or the letter `L` which is then sent into the window procedure to tell the OS to capture it as a global hotkey and foreground the `conhost.exe` that was started. We should realize the load failure and not set any hotkey at all and we should initialize the stack variables. This does both. ## Validation Steps Performed * [x] Manual scenario running LNK file that cannot be loaded from customer report (make LNK to cmd.exe, make it inaccessible to conhost so it can't load/read it.) * [x] Manual scenario with `mklink`'d link that makes the shortcut parser attempt to load (and fail because it isn't a LNK at all from #7650)
claunia added the pull-request label 2026-01-31 09:21:00 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#27276