Commit a430b94
Cygwin: pty: validate the cursor-position reply before moving the pcon cursor
The CSI6n reply handler added in "Cygwin: pty: Fixup pty state after a
cygwin app exits" runs sscanf() on the terminal's response but ignores
its return value, so a malformed or partial reply leaves the x and y
locals uninitialised and hands them to SetConsoleCursorPosition(),
which is exactly the cursor corruption the commit set out to prevent.
Only call the fixup when sscanf() reports both coordinates parsed, and
in fixup_pcon_cursor_position() clamp the coordinates into the valid
SHORT range before the COORD cast so a stray reply cannot wrap into a
negative position. While there, check OpenProcess() for NULL (the
nat-pipe owner may have exited) and check the DuplicateHandle() result
instead of using a possibly-NULL screen-buffer handle.
Fixes: b34394d ("Cygwin: pty: Fixup pty state after a cygwin app exits")
Assisted-by: Opus 4.8
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reviewed-by: Takashi Yano <takashi.yano@nifty.ne.jp>1 parent 60a8889 commit a430b94
1 file changed
Lines changed: 16 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
418 | 418 | | |
419 | 419 | | |
420 | 420 | | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
421 | 425 | | |
422 | 426 | | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
423 | 430 | | |
424 | | - | |
425 | | - | |
426 | | - | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
427 | 438 | | |
428 | 439 | | |
429 | 440 | | |
| |||
2580 | 2591 | | |
2581 | 2592 | | |
2582 | 2593 | | |
2583 | | - | |
2584 | | - | |
| 2594 | + | |
| 2595 | + | |
2585 | 2596 | | |
2586 | 2597 | | |
2587 | 2598 | | |
| |||
0 commit comments