harden the ConPTY backend (Linux-verifiable pre-VM work)
Pre-Windows-VM hardening — the parts validatable on Linux, leaving the unrunnable FFI (Job Object, T-424) for the VM session: - Clamp PTY cols/rows to >= 2 in both backends' spawn + resize (new pty_size.dart). A 1-column ConPTY makes conhost spin emitting CRLF (microsoft/terminal#19922); 0 is invalid on both platforms. - ci/test.sh: --timeout 60s on the dart-test pty line (matches the flutter lines) so a wedged ConPTY reader fails fast instead of hanging the run. - Make windows_pty.dart's pure helpers public + testable off-Windows: quoteArg (MSVCRT quoting), composeEnvironmentBlock, and resolveExecutable (now takes an injectable existence probe). New windows_pty_args_test.dart + pty_size_test.dart give 15 cross-platform assertions over the trickiest Windows logic the on-Windows smoke suite can't reach off-platform. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -25,6 +25,7 @@ import 'dart:typed_data';
|
||||
import 'package:ffi/ffi.dart';
|
||||
|
||||
import 'errors.dart';
|
||||
import 'pty_size.dart';
|
||||
import '../ipc/errno_mapping.dart' show PosixErrno;
|
||||
import 'ffi/libc.dart' as libc;
|
||||
import 'pty_session.dart';
|
||||
@@ -310,8 +311,8 @@ class NativePty implements PtySession {
|
||||
|
||||
// ---- Set initial winsize on the master ---------------------------
|
||||
final ws = calloc<_Winsize>()
|
||||
..ref.wsRow = rows
|
||||
..ref.wsCol = columns;
|
||||
..ref.wsRow = clampPtyDimension(rows)
|
||||
..ref.wsCol = clampPtyDimension(columns);
|
||||
_ioctl(masterFd, _kTiocsWinsz, ws);
|
||||
calloc.free(ws);
|
||||
|
||||
@@ -429,8 +430,8 @@ class NativePty implements PtySession {
|
||||
void resize({required int cols, required int rows}) {
|
||||
if (_dead) return;
|
||||
final ws = calloc<_Winsize>()
|
||||
..ref.wsRow = rows
|
||||
..ref.wsCol = cols;
|
||||
..ref.wsRow = clampPtyDimension(rows)
|
||||
..ref.wsCol = clampPtyDimension(cols);
|
||||
final rc = _ioctl(_fd, _kTiocsWinsz, ws);
|
||||
calloc.free(ws);
|
||||
if (rc < 0 && libc.errno == PosixErrno.ebadf) {
|
||||
|
||||
Reference in New Issue
Block a user