Fix oobread crash in the visual bit pixel editor ##crash

This commit is contained in:
pancake 2023-04-13 11:50:01 +02:00
parent 0b97bd37aa
commit 185eb5afe2
2 changed files with 11 additions and 3 deletions

View File

@ -5556,12 +5556,16 @@ static void bitimage(RCore *core, int cols) {
if (stride < 1) {
stride = 16;
}
stride = 32;
const ut8 *b = core->block;
const int s = core->blocksize;
int x, y;
for (y = 0; y < 8; y++) {
ut8 byte = b[y * stride];
for (x = 8; x > 0; x--) {
size_t pos = y * stride;
if (pos >= s) {
break;
}
ut8 byte = b[pos];
for (x = 7; x >= 0; x--) {
bool pixel = byte & (1 << x);
r_cons_printf ("%s", pixel? "##": "--");
}

View File

@ -523,8 +523,12 @@ R_API bool r_core_visual_bit_editor(RCore *core) {
ut8 *o = core->block;
int bs = core->blocksize;
core->block = buf;
int stride = r_config_get_i (core->config, "hex.stride");
r_config_set_i (core->config, "hex.stride", 1);
core->blocksize = sizeof (buf);
r_core_cmd_call (core, "pri1");
core->block = o;
r_config_set_i (core->config, "hex.stride", stride);
core->blocksize = bs;
}
r_cons_visual_flush ();