Fix crash in server due to overeager parsing
All checks were successful
Build library & run tests / build (unix) (push) Successful in 29s
Build library & run tests / build (tcp) (push) Successful in 29s

This commit is contained in:
2024-06-24 15:58:54 +02:00
parent fc570fa0bd
commit bf183a0598
2 changed files with 29 additions and 16 deletions

View File

@@ -320,7 +320,7 @@ fn derive_protocol(input: proc_macro2::TokenStream) -> proc_macro2::TokenStream
Ok(n) => {
#debug("Received {} bytes (server)", n);
buf.extend_from_slice(&read_buf[..n]);
loop {
while buf.len() >= 4 {
let len = u32::from_le_bytes(buf[..4].try_into().expect("Failed to convert bytes to u32"));
if buf.len() >= (4 + len as usize) {
let serialized = std::str::from_utf8(&buf[4..(4 + len as usize)]).expect("Failed to convert bytes to string");