Bug 1906606 - Sanitize nsCString objects coming from crashed processes r=afranchuk

Also remove some logspam from the test harness.

Differential Revision: https://phabricator.services.mozilla.com/D215899
This commit is contained in:
Gabriele Svelto 2024-07-15 14:47:50 +00:00
parent 8039bfea4c
commit 55422a7dec
2 changed files with 9 additions and 6 deletions

View File

@ -203,9 +203,15 @@ fn copy_nscstring(
if length > 0 {
let data_address = reader.copy_object::<usize>(address)?;
reader
.copy_array::<u8>(data_address, length as _)
.map(ThinVec::from)
let mut vec = reader.copy_array::<u8>(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::<u8>::new())
}

View File

@ -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) {