mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:37:36 +00:00
LibDebug+LibCoredump: Use ByteReader to do unaligned reads
The previous solution of "lol whats a UB" was not nice and tripped over itself when it was run under UBSAN, fix this by doing explicit byte-by-byte reads where needed.
This commit is contained in:
parent
6d64b13a1b
commit
da3c4e5df5
3 changed files with 18 additions and 11 deletions
|
@ -4,6 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/ByteReader.h>
|
||||
#include <AK/HashTable.h>
|
||||
#include <AK/JsonObject.h>
|
||||
#include <AK/JsonValue.h>
|
||||
|
@ -139,8 +140,10 @@ Optional<FlatPtr> Reader::peek_memory(FlatPtr address) const
|
|||
return {};
|
||||
|
||||
FlatPtr offset_in_region = address - region->region_start;
|
||||
const char* region_data = image().program_header(region->program_header_index).raw_data();
|
||||
return *(const FlatPtr*)(®ion_data[offset_in_region]);
|
||||
auto* region_data = bit_cast<const u8*>(image().program_header(region->program_header_index).raw_data());
|
||||
FlatPtr value { 0 };
|
||||
ByteReader::load(region_data + offset_in_region, value);
|
||||
return value;
|
||||
}
|
||||
|
||||
const JsonObject Reader::process_info() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue