Do not treat quit-key bytes as commands for non-interactive stdin #47

Open
opened 2026-05-22 13:05:33 +00:00 by rc · 0 comments
Owner

Finding:
The input forwarding loop always interprets quit_key, even when stdin is not a TTY and raw terminal mode was never enabled.

Problem:

  • Raw mode is gated by isatty, but startForwardingInput always runs.
  • forwardInputLoop scans every input byte for active_quit_key and calls stopVirtualMachineFromConsole.

Impact:
With redirected or piped stdin, a literal byte 0x1d is consumed as a host escape instead of being delivered to the guest. This makes automation and binary/fixture input lossy and surprising.

Suggested fix:
Only enable escape-key handling for interactive TTY input, or add an explicit way to disable the escape key. Non-interactive input should be forwarded byte-for-byte and should close the guest input pipe on EOF.

Relevant code:

  • src/vmz.zig: raw terminal setup and input forwarding loop.
Finding: The input forwarding loop always interprets `quit_key`, even when stdin is not a TTY and raw terminal mode was never enabled. Problem: - Raw mode is gated by `isatty`, but `startForwardingInput` always runs. - `forwardInputLoop` scans every input byte for `active_quit_key` and calls `stopVirtualMachineFromConsole`. Impact: With redirected or piped stdin, a literal byte `0x1d` is consumed as a host escape instead of being delivered to the guest. This makes automation and binary/fixture input lossy and surprising. Suggested fix: Only enable escape-key handling for interactive TTY input, or add an explicit way to disable the escape key. Non-interactive input should be forwarded byte-for-byte and should close the guest input pipe on EOF. Relevant code: - `src/vmz.zig`: raw terminal setup and input forwarding loop.
Sign in to join this conversation.
No labels
highprio
lowprio
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
rc/vmz#47
No description provided.