Skip to content

Commit

Permalink
Fix buffer overread in format_escaped_str
Browse files Browse the repository at this point in the history
Fixes #452, probably.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
  • Loading branch information
andersk authored and ijl committed Feb 14, 2024
1 parent c825472 commit 29884e6
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/serialize/writer/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ macro_rules! impl_format_simd {
}

while nb > 0 {
let v = StrVector::from_slice(core::slice::from_raw_parts(sptr, STRIDE));
let mut v = StrVector::default();
v.as_mut_array()[..nb].copy_from_slice(core::slice::from_raw_parts(sptr, nb));
v.copy_to_slice(core::slice::from_raw_parts_mut(dptr, STRIDE));
let mask = (v.simd_eq(blash) | v.simd_eq(quote) | v.simd_lt(x20)).to_bitmask()
as u32
Expand Down

0 comments on commit 29884e6

Please sign in to comment.