1
0
mirror of synced 2024-11-28 09:30:51 +01:00

fix: Out of bounds memory read in hex editor with multi-byte visualizers

This commit is contained in:
WerWolv 2022-07-30 22:44:02 +02:00
parent 9ede1ab32c
commit 45ea22083e

View File

@ -704,7 +704,7 @@ namespace hex::plugin::builtin {
const auto cellBytes = std::min<u64>(validBytes, bytesPerCell);
// Query cell colors
if (x < validBytes) {
if (x < validBytes / bytesPerCell) {
const auto foregroundColor = queryForegroundColor(byteAddress, &bytes[x * cellBytes], cellBytes);
const auto backgroundColor = [&]{
auto color = queryBackgroundColor(byteAddress, &bytes[x * cellBytes], cellBytes);
@ -740,7 +740,7 @@ namespace hex::plugin::builtin {
if (isColumnSeparatorColumn(x, columnCount))
ImGui::TableNextColumn();
if (x < validBytes) {
if (x < validBytes / bytesPerCell) {
auto cellStartPos = getCellPosition();
auto cellSize = (CharacterSize * ImVec2(this->m_currDataVisualizer->getMaxCharsPerCell(), 1) + (ImVec2(3, 2) * ImGui::GetStyle().CellPadding) - ImVec2(1, 0) * ImGui::GetStyle().CellPadding) + ImVec2(1, 0);
@ -860,7 +860,7 @@ namespace hex::plugin::builtin {
const auto x = address % this->m_bytesPerRow;
if (x < validBytes) {
if (x < validBytes / bytesPerCell) {
auto [foregroundColor, backgroundColor] = cellColors[x / bytesPerCell];
// Draw highlights and selection