mirror of
https://github.com/haileys/bark
synced 2024-11-10 05:54:15 +00:00
fix buffer size passed to socket.recv_from
This commit is contained in:
parent
e90f25f8b0
commit
fa1d3fc68b
2 changed files with 5 additions and 1 deletions
|
@ -38,7 +38,7 @@ impl Protocol {
|
|||
loop {
|
||||
let mut buffer = PacketBuffer::allocate();
|
||||
|
||||
let (nbytes, peer) = self.socket.recv_from(buffer.as_bytes_mut())?;
|
||||
let (nbytes, peer) = self.socket.recv_from(buffer.as_full_buffer_mut())?;
|
||||
buffer.set_len(nbytes);
|
||||
|
||||
if let Some(packet) = Packet::from_buffer(buffer) {
|
||||
|
|
|
@ -49,6 +49,10 @@ impl PacketBuffer {
|
|||
pub fn as_bytes_mut(&mut self) -> &mut [u8] {
|
||||
&mut self.raw[0..self.len]
|
||||
}
|
||||
|
||||
pub fn as_full_buffer_mut(&mut self) -> &mut [u8] {
|
||||
&mut self.raw
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
|
|
Loading…
Reference in a new issue