Fix regression in wo2/4/8

This commit is contained in:
pancake 2019-09-03 09:49:14 +02:00
parent 4cede2ed45
commit 865fd0b902
2 changed files with 11 additions and 16 deletions

View File

@ -240,13 +240,13 @@ R_API ut8* r_core_transform_op(RCore *core, const char *arg, char op) {
} else {
eprintf ("Invalid word size. Use 1, 2, 4 or 8\n");
}
} else if (op == '2' || op == '4' || op == '8') {
} else if (op == '2' || op == '4' || op == '8') { // "wo2" "wo4" "wo8"
int inc = op - '0';
ut8 tmp;
if (inc < 1 || inc > 8) {
goto beach;
}
for (i = 0; (i + inc) < core->blocksize - inc; i += inc) {
for (i = 0; (i + inc) <= core->blocksize; i += inc) {
if (inc == 2) {
tmp = buf[i];
buf[i] = buf[i+1];
@ -315,23 +315,18 @@ beach:
}
R_API int r_core_write_op(RCore *core, const char *arg, char op) {
int ret;
ut8 *buf;
buf = r_core_transform_op(core, arg, op);
ut8 *buf = r_core_transform_op(core, arg, op);
if (!buf) {
return false;
}
ret = r_core_write_at(core, core->offset, buf, core->blocksize);
free(buf);
int ret = r_core_write_at (core, core->offset, buf, core->blocksize);
free (buf);
return ret;
}
static void __choose_bits_anal_hints(RCore *core, ut64 addr, int *bits) {
if (core->anal) {
int ret = r_anal_range_tree_find_bits_at (core->anal->rb_hints_ranges,
addr);
int ret = r_anal_range_tree_find_bits_at (core->anal->rb_hints_ranges, addr);
if (ret) {
*bits = ret;
}

View File

@ -320,15 +320,15 @@ static void cmd_write_op (RCore *core, const char *input) {
case 'd':
case 'o':
case 'w':
case '2':
case '4':
case '2': // "wo2"
case '4': // "wo4"
case '8': // "wo8"
if (input[2]) { // parse val from arg
r_core_write_op (core, input+3, input[1]);
r_core_block_read (core);
r_core_write_op (core, input + 3, input[1]);
} else { // use clipboard instead of val
r_core_write_op (core, NULL, input[1]);
r_core_block_read (core);
}
r_core_block_read (core);
break;
case 'R':
r_core_cmd0 (core, "wr $b");