terminal icon indicating copy to clipboard operation
terminal copied to clipboard

COOKED_READ: cmd.exe tab fails to erase trailing characters

Open lhecker opened this issue 1 year ago • 1 comments

Windows build number

10.0.26052.0

Steps to reproduce

  • Launch cmd.exe
  • Type foo bar
  • Move the cursor the space after foo
  • Press tab

Expected Behavior

The prompt reads foo.

Actual Behavior

The prompt reads foo bar and trailing bar is inaccessible.

lhecker avatar Feb 12 '24 21:02 lhecker

No way... This reproduces all the way back to conhost v1 lol. At this point we've found ReadConsole's dwCtrlWakeupMask API:

  • overwrote the character under the cursor with the control character even though it wasn't ever intended to do that
  • allowed you read beyond the end of the initialized buffer
  • assumed that 1 char = 1 column despite being added after the W APIs got added
  • ✨NEW✨ doesn't even erase the end of the prompt

At this point I finally got to say: Kudos to the people who designed, implemented and reviewed the CONSOLE_READCONSOLE_CONTROL API. Whoever you all are, all of you did a. fantastic. job.

lhecker avatar Feb 15 '24 16:02 lhecker