Skip to content

Commit

Permalink
Fix overflow in delimiter_of_raw_string at end of input
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jun 25, 2023
1 parent cfa1524 commit 4207faa
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,22 +468,20 @@ fn cooked_byte_string(mut input: Cursor) -> Result<Cursor, Reject> {
}

fn delimiter_of_raw_string(input: Cursor) -> PResult<&str> {
let mut n = 0;
for (i, byte) in input.bytes().enumerate() {
match byte {
b'"' => {
n = i;
break;
if i > 255 {
// https://github.com/rust-lang/rust/pull/95251
return Err(Reject);
}
return Ok((input.advance(i + 1), &input.rest[..i]));
}
b'#' => {}
_ => return Err(Reject),
_ => break,
}
}
if n > 255 {
// https://github.com/rust-lang/rust/pull/95251
return Err(Reject);
}
Ok((input.advance(n + 1), &input.rest[..n]))
Err(Reject)
}

fn raw_byte_string(input: Cursor) -> Result<Cursor, Reject> {
Expand Down

0 comments on commit 4207faa

Please sign in to comment.