Fix UTF-8 slicing panics: use floor_char_boundary for all truncation
Byte-position truncation (&s[..s.len().min(N)]) panics when position N lands inside a multi-byte character. Fixed in parser debug logging, API error messages, oneshot response logging, and CLI agent display. Also fixed tool dispatch permissions (removed global fallback). Co-Authored-By: Proof of Concept <poc@bcachefs.org>
This commit is contained in:
parent
1776222b07
commit
fba8fcc587
6 changed files with 12 additions and 10 deletions
|
|
@ -245,7 +245,7 @@ pub(crate) async fn send_and_check(
|
|||
status,
|
||||
elapsed.as_secs_f64(),
|
||||
url,
|
||||
&body[..body.len().min(500)]
|
||||
&body[..body.floor_char_boundary(body.len().min(500))]
|
||||
);
|
||||
if let Some(json) = request_json {
|
||||
let log_dir = dirs::home_dir()
|
||||
|
|
@ -260,7 +260,7 @@ pub(crate) async fn send_and_check(
|
|||
);
|
||||
}
|
||||
}
|
||||
anyhow::bail!("HTTP {} ({}): {}", status, url, &body[..body.len().min(1000)]);
|
||||
anyhow::bail!("HTTP {} ({}): {}", status, url, &body[..body.floor_char_boundary(body.len().min(1000))]);
|
||||
}
|
||||
|
||||
if debug {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue