Skip to content

Commit

Permalink
Use from_bytes_until_nul to avoid problems with multiple nuls.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidblewett committed Jan 19, 2024
1 parent e69c2aa commit 2a7b528
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ impl NativeClientConfig {
}

// Convert the C string to a Rust string.
Ok(String::from_utf8_lossy(&buf).to_string())
let cstr = CStr::from_bytes_until_nul(&buf)
.unwrap()
.to_string_lossy()
.into();
Ok(cstr)
}
}

Expand Down

0 comments on commit 2a7b528

Please sign in to comment.