Skip to content

Commit

Permalink
limit string to the received message size
Browse files Browse the repository at this point in the history
  • Loading branch information
stlankes committed Feb 13, 2024
1 parent 929d622 commit 0687236
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion examples/mioudp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn main() -> io::Result<()> {
Ok((packet_size, source_address)) => {
// Echo the data.
socket.send_to(&buf[..packet_size], source_address)?;
if let Ok(str_buf) = from_utf8(&buf) {
if let Ok(str_buf) = from_utf8(&buf[..packet_size]) {
if str_buf.trim_end() == "exit" {
std::process::exit(0);
}
Expand Down

0 comments on commit 0687236

Please sign in to comment.