From 3c5309a302bfdaaadf4b12e57dfd990813ae1902 Mon Sep 17 00:00:00 2001 From: Gabriele Svelto Date: Thu, 7 Dec 2023 08:41:54 +0100 Subject: [PATCH] Do not assume that the debug file string is as long as the array in which it is stored This fixes issue #824 --- symbolic-debuginfo/src/pe.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/symbolic-debuginfo/src/pe.rs b/symbolic-debuginfo/src/pe.rs index 7c5c75e9..abfd1cc3 100644 --- a/symbolic-debuginfo/src/pe.rs +++ b/symbolic-debuginfo/src/pe.rs @@ -154,8 +154,12 @@ impl<'data> PeObject<'data> { .debug_data .as_ref() .and_then(|debug_data| debug_data.codeview_pdb70_debug_info.as_ref()) - .map(|debug_info| { - String::from_utf8_lossy(&debug_info.filename[..debug_info.filename.len() - 1]) + .and_then(|debug_info| { + debug_info + .filename + .iter() + .position(|&c| c == 0) + .map(|nul_byte| String::from_utf8_lossy(&debug_info.filename[..nul_byte])) }) }