Skip to content

fix(tunnel): don't split a multibyte char when trimming the ssh stderr tail - #176

Open
56steve wants to merge 1 commit into
Petyok:developmentfrom
56steve:fix/tunnel-stderr-tail-boundary
Open

56steve wants to merge 1 commit into
Petyok:developmentfrom
56steve:fix/tunnel-stderr-tail-boundary

Conversation

@56steve

@56steve 56steve commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

The tunnel manager keeps the last few KB of each ssh process's stderr. Once that buffer passed 8192 bytes it cut it down with drain(..len - 4096), a byte offset, so when the cut landed inside a multibyte character (any non-ASCII ssh message, a localized error or a hostname) String::drain panicked in the stderr reader thread.

I moved the append and trim into push_stderr_line and made it step back to a character boundary before draining, the same way push_capped in session/mod.rs already does. The new test pushes lines of two-byte characters past the cap repeatedly; it panicked before the change and now keeps the buffer under the cap. I also added a CHANGELOG entry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant