rust-lang / rust-lang/ssh2-rs

panic Utf8Error

Open
#319 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Thank you for this library, but I found a problem. I have a non-utf8 encoded file on my server. When I access the server path on the Windows platform, it panics.

called Result::unwrap() on an Err value: Utf8Error { valid_up_to: 10, error_len: Some(1) }

sftp.readdir(&Path::new("/usr/xxxx/"));
#[cfg(windows)]
fn mkpath(v: Vec<u8>) -> PathBuf {
    use std::str;
    PathBuf::from(str::from_utf8(&v).unwrap())
}

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 Windows-only mkpath function shown in the report and trace how sftp.readdir supplies its byte path. Reproduce the issue with a non-UTF-8 filename and verify that handling the path no longer panics.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.