mirror of
https://gitlab.redox-os.org/CoffeeCode/redox-ssh.git
synced 2025-12-28 18:42:18 +01:00
Fix bug with discarded buffer
This commit is contained in:
parent
673ba67f61
commit
c44b63c32c
1 changed files with 4 additions and 4 deletions
|
|
@ -42,11 +42,12 @@ impl<W: Write> Connection<W> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn run(&mut self, mut stream: &mut Read) -> ConnectionResult<()> {
|
pub fn run(&mut self, stream: &mut Read) -> ConnectionResult<()> {
|
||||||
self.stream.write(self.my_id.as_bytes())?;
|
self.stream.write(self.my_id.as_bytes())?;
|
||||||
self.stream.flush()?;
|
self.stream.flush()?;
|
||||||
|
|
||||||
self.peer_id = Some(self.read_id(stream)?);
|
let mut stream = BufReader::new(stream);
|
||||||
|
self.peer_id = Some(self.read_id(&mut stream)?);
|
||||||
|
|
||||||
if let Some(ref peer_id) = self.peer_id {
|
if let Some(ref peer_id) = self.peer_id {
|
||||||
println!("Identifies as {:?}", peer_id);
|
println!("Identifies as {:?}", peer_id);
|
||||||
|
|
@ -59,11 +60,10 @@ impl<W: Write> Connection<W> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn read_id(&mut self, stream: &mut Read) -> io::Result<String> {
|
fn read_id(&mut self, mut reader: &mut BufRead) -> io::Result<String> {
|
||||||
// The identification string has a maximum length of 255 bytes
|
// The identification string has a maximum length of 255 bytes
|
||||||
// TODO: Make sure to stop reading if the client sends too much
|
// TODO: Make sure to stop reading if the client sends too much
|
||||||
|
|
||||||
let mut reader = BufReader::new(stream);
|
|
||||||
let mut id = String::new();
|
let mut id = String::new();
|
||||||
|
|
||||||
while !id.starts_with("SSH-") {
|
while !id.starts_with("SSH-") {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue