mirror of
https://github.com/radareorg/radare2.git
synced 2024-11-30 16:40:57 +00:00
Fix oobread crash in the visual bit pixel editor ##crash
This commit is contained in:
parent
0b97bd37aa
commit
185eb5afe2
@ -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? "##": "--");
|
||||
}
|
||||
|
@ -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 ();
|
||||
|
Loading…
Reference in New Issue
Block a user