Skip to content

Commit

Permalink
fix(protocol): Don't reserve memory on packet decoding error (#360)
Browse files Browse the repository at this point in the history
* fix(protocol): Don't reserve memory on packet decoding error

* fix: revert packet_decoder fix part, this need more test for the moment

* fix: drop the connection on decoding error to avoid possible attack
  • Loading branch information
HookWoods authored Dec 1, 2024
1 parent f29cfbc commit 1fd966f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pumpkin/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,11 @@ impl Client {
return true;
}
Ok(None) => (), //log::debug!("Waiting for more data to complete packet..."),
Err(err) => log::warn!("Failed to decode packet for: {}", err.to_string()),
Err(err) => {
log::warn!("Failed to decode packet for: {}", err.to_string());
self.close();
return false; // return to avoid reserving additional bytes
}
}

dec.reserve(4096);
Expand Down

0 comments on commit 1fd966f

Please sign in to comment.