Skip to content

Commit fbadaf8

Browse files
committed
Fix handling of empty line.
1 parent e71a4c9 commit fbadaf8

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/Renci.SshNet/Connection/HttpConnector.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,13 @@ private static string SocketReadLine(Socket socket, TimeSpan timeout)
118118
break;
119119

120120
var b = data[0];
121+
buffer.Add(b);
121122

122-
if (b == Session.LineFeed && buffer.Count > 1 && buffer[buffer.Count - 1] == Session.CarriageReturn)
123+
if (b == Session.LineFeed && buffer.Count > 1 && buffer[buffer.Count - 2] == Session.CarriageReturn)
123124
{
124-
// Return line without CR
125-
return encoding.GetString(buffer.ToArray(), 0, buffer.Count - 1);
125+
// Return line without CRLF
126+
return encoding.GetString(buffer.ToArray(), 0, buffer.Count - 2);
126127
}
127-
128-
buffer.Add(b);
129128
}
130129
while (true);
131130

0 commit comments

Comments
 (0)