diff --git a/toolkit/crashreporter/mozannotation_server/src/lib.rs b/toolkit/crashreporter/mozannotation_server/src/lib.rs index ca48b78d188b..bce2d5108f4a 100644 --- a/toolkit/crashreporter/mozannotation_server/src/lib.rs +++ b/toolkit/crashreporter/mozannotation_server/src/lib.rs @@ -203,9 +203,15 @@ fn copy_nscstring( if length > 0 { let data_address = reader.copy_object::(address)?; - reader - .copy_array::(data_address, length as _) - .map(ThinVec::from) + let mut vec = reader.copy_array::(data_address, length as _)?; + + // Ensure that the string contains no nul characters. + let nul_byte_pos = vec.iter().position(|&c| c == 0); + if let Some(nul_byte_pos) = nul_byte_pos { + vec.truncate(nul_byte_pos); + } + + Ok(ThinVec::from(vec)) } else { Ok(ThinVec::::new()) } diff --git a/toolkit/crashreporter/test/unit/head_crashreporter.js b/toolkit/crashreporter/test/unit/head_crashreporter.js index 34602e210743..c37c8acf8c53 100644 --- a/toolkit/crashreporter/test/unit/head_crashreporter.js +++ b/toolkit/crashreporter/test/unit/head_crashreporter.js @@ -156,9 +156,6 @@ async function handleMinidump(callback) { registerCleanupFunction(cleanup); Assert.ok(extrafile.exists()); - let data = await IOUtils.read(extrafile.path); - let decoder = new TextDecoder("ascii"); - console.log("data = " + decoder.decode(data)); let extra = await IOUtils.readJSON(extrafile.path); if (callback) {