From b32a6da6f62561bf4fd3dbf9e8098eb52188e3a5 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Mon, 5 Feb 2024 13:47:34 -0800 Subject: [PATCH] Fix buffer overread in format_escaped_str Fixes #452, probably. Signed-off-by: Anders Kaseorg --- src/serialize/writer/simd.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/serialize/writer/simd.rs b/src/serialize/writer/simd.rs index 1dcc9fce..fe4a0dcf 100644 --- a/src/serialize/writer/simd.rs +++ b/src/serialize/writer/simd.rs @@ -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