sshnet / sshnet/SSH.NET

Issue with NetConf : ArgumentOutOfRangeException

Open
#69 2 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

When an rpc-reply message is received, this exception is thrown in NetconfSession.OnDataReceived event handler.
The cause is that the received data length is 1015 byte, and the decoded message string contains a magic number at the beginning as below:
#1585

....

This number is matched with a regex then is used to append this length of data to a stringbuilder, namely to _rpcreply object, like :

var match = Regex.Match(chunk.Substring(position), @"\n#(?<length>\d+)\n");
if (!match.Success)
{
  break;
}
var fractionLength = Convert.ToInt32(match.Groups["length"].Value);
_rpcReply.Append(chunk, position + match.Index + match.Length, fractionLength);

where the value of position is the number at the beginning of the message, that is, 1585 in this example.
It is obvious that the Append operation will fail as one can't append 1585 byte from an 1015 byte length string.

What I can't figure out is where this magic number is coming from, as RFC6241 apparently does not contain such - lets call it - segment length element ? So where is it coming from, can anyone tell ?

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 in NetconfSession.OnDataReceived, focusing on the regex that reads the #length marker and the _rpcReply append operation. Compare this framing with the relevant NETCONF specification and inspect how received chunks are split. Done means identifying the marker's source and resolving the out-of-range failure for the reported rpc-reply.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.