rust-lang / rust-lang/ssh2-rs

Session::channel_open should probably not restrict the message to UTF-8

Open
#247 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Rust
Stars
566
Forks
163
Avg merge
4h 51m
Merged PRs (30d)
2

Description

The message argument for Session::channel_open is currently an Option<&str>, while sometimes it's necessary to pass arbitrary binary data to libssh2_channel_open_ex. For example, inside libssh2 itself, raw u32 values are passed inside the string, which can make it invalid UTF-8:

https://github.com/libssh2/libssh2/blob/d39e9ccc5e08a6441075049f1f79ffcb2bbe5a52/src/channel.c#L406

The parameters should probably be Option<&[u8]>, or a generic involving AsRef<[u8]> but there's probably no way to fix the existing method without making a breaking change, but adding a new method feels clunky too.

I could create a PR if this is something you'd consider fixing.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Session::channel_open entry point and compare its message argument with the libssh2_channel_open_ex call. Read the referenced libssh2 src/channel.c code to understand the binary data requirement and determine a compatible API path. Done means channel-open messages can carry arbitrary bytes without requiring UTF-8, with the API implications resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.