From 7528a765fbddfcf03da0d0ceee6e25609c36350c Mon Sep 17 00:00:00 2001 From: Gabi Date: Fri, 17 Nov 2023 01:13:45 -0300 Subject: [PATCH] connlib: fix incorrect assumption for buffer size that was causing panics (#2663) There was an incorrect assumption with buffer size that was causing a panic (detected on macos client) --- rust/connlib/tunnel/src/peer.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rust/connlib/tunnel/src/peer.rs b/rust/connlib/tunnel/src/peer.rs index a5c0baa64..eb4cf4ea3 100644 --- a/rust/connlib/tunnel/src/peer.rs +++ b/rust/connlib/tunnel/src/peer.rs @@ -19,6 +19,7 @@ use parking_lot::{Mutex, RwLock}; use pnet_packet::Packet; use secrecy::ExposeSecret; +use crate::MAX_UDP_SIZE; use crate::{ device_channel, ip_packet::MutableIpPacket, resource_table::ResourceTable, PeerConfig, }; @@ -225,9 +226,7 @@ where TunnResult::WriteToNetwork(packet) => { let mut packets = VecDeque::from([Bytes::copy_from_slice(packet)]); - // Boringtun requires us to call `decapsulate` repeatedly if it returned `WriteToNetwork`. - // However, for the repeated calls, we only need a buffer of at most 148 bytes which we can easily allocate on the stack. - let mut buf = [0u8; 148]; + let mut buf = [0u8; MAX_UDP_SIZE]; while let TunnResult::WriteToNetwork(packet) = tunnel.decapsulate(None, &[], &mut buf)