Skip to content

Commit

Permalink
Fix #2910 - two oob read with the command wo2
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarofe authored and radare committed Jul 13, 2015
1 parent be7b1ed commit 76c5cc9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions libr/core/cmd_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ static void cmd_write_op (RCore *core, const char *input) {
}
case '2':
case '4':
r_core_write_op (core, input+3, input[1]);
r_core_block_read (core, 0);
if (input[2]){
r_core_write_op (core, input+3, input[1]);
r_core_block_read (core, 0);
}
break;
case 'R':
r_core_cmd0 (core, "wr $b");
Expand Down
3 changes: 2 additions & 1 deletion libr/core/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ R_API int r_core_write_op(RCore *core, const char *arg, char op) {
} else
if (op=='2' || op=='4') {
op -= '0';
for (i=0; i<core->blocksize; i+=op) {
// if i < core->blocksize would pass the test but buf[i+3] goes beyond the buffer
for (i=0; i<core->blocksize-3; i+=op) {
/* endian swap */
ut8 tmp = buf[i];
buf[i] = buf[i+3];
Expand Down

0 comments on commit 76c5cc9

Please sign in to comment.