summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock2
-rw-r--r--Cargo.toml2
-rw-r--r--src/client.rs5
3 files changed, 5 insertions, 4 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 6462b45..31d5741 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -467,7 +467,7 @@ dependencies = [
[[package]]
name = "tcpmux"
-version = "0.1.0"
+version = "0.1.1"
dependencies = [
"clap",
"serde",
diff --git a/Cargo.toml b/Cargo.toml
index 0f8ca6a..616da93 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "tcpmux"
-version = "0.1.0"
+version = "0.1.1"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
diff --git a/src/client.rs b/src/client.rs
index 1e2edc4..3fcf78f 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -57,14 +57,15 @@ pub async fn handle_client(
}
if b == b'\n' && prev_is_cr {
if i < msg.len() {
- i -= 2; // remove CRLF from reported message string
+ i -= 1; // remove CRLF from reported message string
}
break;
}
i += 1;
prev_is_cr = b == b'\r';
}
- let msg = match std::str::from_utf8(&msg[..i]) {
+ let msg = if i < msg.len() { &msg[..i] } else { &msg };
+ let msg = match std::str::from_utf8(msg) {
Ok(s) => s,
Err(why) => {
warn!(