Skip to content

Commit 220f681

Browse files
committed
fixed buffer overflooding in ShowMenu function
1 parent a70c763 commit 220f681

File tree

6 files changed

+12
-42
lines changed

6 files changed

+12
-42
lines changed

src/Sophia_Script_for_Windows_10/Module/Sophia.psm1

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6929,18 +6929,13 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
69296929
$Default
69306930
)
69316931

6932-
# There's a bug in Windows Terminal with double text in console
6933-
# https://github.com/microsoft/terminal/issues/14992
6934-
if ($env:WT_SESSION)
6935-
{
6936-
Clear-Host
6937-
}
6938-
69396932
Write-Information -MessageData $Title -InformationAction Continue
69406933
Write-Information -MessageData "" -InformationAction Continue
69416934

69426935
# Extract the localized "Skip" string from shell32.dll
69436936
$Menu += [WinAPI.GetStr]::GetString(16956)
6937+
# https://github.com/microsoft/terminal/issues/14992
6938+
[System.Console]::BufferHeight += $Menu.Count
69446939
$minY = [Console]::CursorTop
69456940
$y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0)
69466941

src/Sophia_Script_for_Windows_10_LTSC_2019/Module/Sophia.psm1

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5616,18 +5616,13 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
56165616
$Default
56175617
)
56185618

5619-
# There's a bug in Windows Terminal with double text in console
5620-
# https://github.com/microsoft/terminal/issues/14992
5621-
if ($env:WT_SESSION)
5622-
{
5623-
Clear-Host
5624-
}
5625-
56265619
Write-Information -MessageData $Title -InformationAction Continue
56275620
Write-Information -MessageData "" -InformationAction Continue
56285621

56295622
# Extract the localized "Skip" string from shell32.dll
56305623
$Menu += [WinAPI.GetStr]::GetString(16956)
5624+
# https://github.com/microsoft/terminal/issues/14992
5625+
[System.Console]::BufferHeight += $Menu.Count
56315626
$minY = [Console]::CursorTop
56325627
$y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0)
56335628

src/Sophia_Script_for_Windows_10_LTSC_2021/Module/Sophia.psm1

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6003,18 +6003,13 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
60036003
$Default
60046004
)
60056005

6006-
# There's a bug in Windows Terminal with double text in console
6007-
# https://github.com/microsoft/terminal/issues/14992
6008-
if ($env:WT_SESSION)
6009-
{
6010-
Clear-Host
6011-
}
6012-
60136006
Write-Information -MessageData $Title -InformationAction Continue
60146007
Write-Information -MessageData "" -InformationAction Continue
60156008

60166009
# Extract the localized "Skip" string from shell32.dll
60176010
$Menu += [WinAPI.GetStr]::GetString(16956)
6011+
# https://github.com/microsoft/terminal/issues/14992
6012+
[System.Console]::BufferHeight += $Menu.Count
60186013
$minY = [Console]::CursorTop
60196014
$y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0)
60206015

src/Sophia_Script_for_Windows_10_PowerShell_7/Module/Sophia.psm1

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6938,18 +6938,13 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
69386938
$Default
69396939
)
69406940

6941-
# There's a bug in Windows Terminal with double text in console
6942-
# https://github.com/microsoft/terminal/issues/14992
6943-
if ($env:WT_SESSION)
6944-
{
6945-
Clear-Host
6946-
}
6947-
69486941
Write-Information -MessageData $Title -InformationAction Continue
69496942
Write-Information -MessageData "" -InformationAction Continue
69506943

69516944
# Extract the localized "Skip" string from shell32.dll
69526945
$Menu += [WinAPI.GetStr]::GetString(16956)
6946+
# https://github.com/microsoft/terminal/issues/14992
6947+
[System.Console]::BufferHeight += $Menu.Count
69536948
$minY = [Console]::CursorTop
69546949
$y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0)
69556950

src/Sophia_Script_for_Windows_11/Module/Sophia.psm1

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6498,18 +6498,13 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
64986498
$Default
64996499
)
65006500

6501-
# There's a bug in Windows Terminal with double text in console
6502-
# https://github.com/microsoft/terminal/issues/14992
6503-
if ($env:WT_SESSION)
6504-
{
6505-
Clear-Host
6506-
}
6507-
65086501
Write-Information -MessageData "" -InformationAction Continue
65096502
Write-Information -MessageData $Title -InformationAction Continue
65106503

65116504
# Extract the localized "Skip" string from shell32.dll
65126505
$Menu += [WinAPI.GetStr]::GetString(16956)
6506+
# https://github.com/microsoft/terminal/issues/14992
6507+
[System.Console]::BufferHeight += $Menu.Count
65136508
$minY = [Console]::CursorTop
65146509
$y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0)
65156510

src/Sophia_Script_for_Windows_11_PowerShell_7/Module/Sophia.psm1

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6505,18 +6505,13 @@ public extern static int SHSetKnownFolderPath(ref Guid folderId, uint flags, Int
65056505
$Default
65066506
)
65076507

6508-
# There's a bug in Windows Terminal with double text in console
6509-
# https://github.com/microsoft/terminal/issues/14992
6510-
if ($env:WT_SESSION)
6511-
{
6512-
Clear-Host
6513-
}
6514-
65156508
Write-Information -MessageData $Title -InformationAction Continue
65166509
Write-Information -MessageData "" -InformationAction Continue
65176510

65186511
# Extract the localized "Skip" string from shell32.dll
65196512
$Menu += [WinAPI.GetStr]::GetString(16956)
6513+
# https://github.com/microsoft/terminal/issues/14992
6514+
[System.Console]::BufferHeight += $Menu.Count
65206515
$minY = [Console]::CursorTop
65216516
$y = [Math]::Max([Math]::Min($Default, $Menu.Count), 0)
65226517

0 commit comments

Comments
 (0)