Skip to content

Commit 1d43be1

Browse files
committed
Auto merge of #12468 - arlosi:http-debug-crash, r=weihanglo
Fix panic when enabling http.debug for certain strings Fixes an issue where enabling HTTP debugging may attempt to slice a string across a character boundary resulting in a panic. This likely occurs when binary HTTP data happens to be valid UTF-8. By interpreting the strings as `&[u8]` before slicing, (which is what `eq_ignore_ascii_case` did internally anyway), the panic is no longer possible. Closes #12459 r? `@weihanglo`
2 parents 2b3554f + 13f1da9 commit 1d43be1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/cargo/util/network/http.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ pub fn configure_http_handle(config: &Config, handle: &mut Easy) -> CargoResult<
152152
_ => return,
153153
};
154154
let starts_with_ignore_case = |line: &str, text: &str| -> bool {
155+
let line = line.as_bytes();
156+
let text = text.as_bytes();
155157
line[..line.len().min(text.len())].eq_ignore_ascii_case(text)
156158
};
157159
match str::from_utf8(data) {

0 commit comments

Comments
 (0)