@samitouri / QOSAMI-WSL / commits / f2d87e07

Fix unvalidated TerminalProfileSize during distribution import (#41495)

* Fix unvalidated TerminalProfileSize when importing a distribution _ProcessImportResultMessage constructed the terminal profile string_view using the message-supplied TerminalProfileSize without validating it against the received buffer length. Use the bounds-checked two-argument span::subspan() overload (matching the existing ShortcutIconSize handling a few lines above) so an inconsistent size value throws instead of producing a string_view that runs past the end of the buffer. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 35281c30-3d08-4f05-8c84-2ce4711023d5 * format source --------- Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 35281c30-3d08-4f05-8c84-2ce4711023d5

Ben Hillis committed Sep 2, 2026 at 09:12 UTC f2d87e0735c7bba3f3035071869875b18909cf94
1 file changed +3 -2
src/windows/service/exe/LxssUserSession.cpp
+3 -2
@@ -3509,8 +3509,9 @@ void LxssUserSessionImpl::_ProcessImportResultMessage(
3509 {
3510 if (Message.TerminalProfileIndex != 0)
3511 {
3512 - const auto terminalProfileSpan = Span.subspan(Message.TerminalProfileIndex);
3513 - const std::string_view terminalProfile(reinterpret_cast<const char*>(terminalProfileSpan.data()), Message.TerminalProfileSize);
3512 + const auto terminalProfileSpan = Span.subspan(Message.TerminalProfileIndex, Message.TerminalProfileSize);
3513 + const std::string_view terminalProfile(
3514 + reinterpret_cast<const char*>(terminalProfileSpan.data()), terminalProfileSpan.size());
3515 _CreateTerminalProfile(terminalProfile, iconPath, Configuration, Registration);
3516 }
3517 else