From 569910856e648e8cdaad85916eb82fea3c75ed8b Mon Sep 17 00:00:00 2001 From: Aapo Alasuutari Date: Fri, 5 Aug 2022 19:26:54 +0300 Subject: fix(ext/ffi): Check CStr for UTF-8 validity on read (#15318) Co-authored-by: Phosra --- test_ffi/src/lib.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test_ffi/src') diff --git a/test_ffi/src/lib.rs b/test_ffi/src/lib.rs index b061ca8d5..08ef7cb7f 100644 --- a/test_ffi/src/lib.rs +++ b/test_ffi/src/lib.rs @@ -411,3 +411,10 @@ static STRING: &str = "Hello, world!\0"; extern "C" fn ffi_string() -> *const u8 { STRING.as_ptr() } + +/// Invalid UTF-8 characters, array of length 14 +#[no_mangle] +pub static static_char: [u8; 14] = [ + 0xC0, 0xC1, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF, + 0x00, +]; -- cgit v1.2.3