sshnet / sshnet/SSH.NET

Exception when reading sftp extensions

Open
#726 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
4.4k
Forks
993
Avg merge
9d 21h
Merged PRs (30d)
1

Description

Hello,

I encounter the following exception reading the SFTP extensions => An item with the same key has already been added

The server is returning a duplicate extension : posix-rename@openssh.com which make failed the dictionary Add in ReadExtensionPair().

I know the server shouldn't return twice the extension but I think it would be good to not fail and maybe to keep the last key/value pair received.

I can submit a fix. What do you think ?

Regards

---------- EXCEPTION -------------
System.ArgumentException: An item with the same key has already been added.
at Renci.SshNet.SubsystemSession.WaitOnHandle(WaitHandle waitHandle, Int32 millisecondsTimeout)
at Renci.SshNet.Sftp.SftpSession.OnChannelOpen()
at Renci.SshNet.SubsystemSession.Connect()
at Renci.SshNet.SftpClient.OnConnected()
at Renci.SshNet.BaseClient.Connect()

Contributor guide

Open the contributing guide

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 ReadExtensionPair(), identified as the failing dictionary insertion point, and reproduce the SFTP connection against a server returning duplicate posix-rename@openssh.com extensions. Confirm that duplicate extensions no longer raise the reported exception and that the resulting extension value follows the issue's requested last-pair behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
networking
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.