Skip to content

Commit b9f3f1b

Browse files
committed
Fix #24425 - Oobread in pv -1 ##crash
1 parent fa1b013 commit b9f3f1b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

libr/core/cmd_print.inc.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4121,7 +4121,7 @@ static void cmd_print_pv(RCore *core, const char *input, bool useBytes) {
41214121
const char *arg = strchr (input, ' ');
41224122
arg = arg? r_str_trim_head_ro (arg + 1): input;
41234123

4124-
ut64 repeat = r_num_math (core->num, arg);
4124+
st64 repeat = r_num_math (core->num, arg);
41254125
if (repeat < 0) {
41264126
repeat = 1;
41274127
}
@@ -4346,7 +4346,14 @@ static void cmd_print_pv(RCore *core, const char *input, bool useBytes) {
43464346
heaped_block = calloc (repeat + 8, n);
43474347
r_io_read_at (core->io, core->addr, heaped_block, bs);
43484348
block = heaped_block;
4349+
bool breaks = repeat > 1024;
4350+
if (breaks) {
4351+
r_cons_break_push (core->cons, NULL, NULL);
4352+
}
43494353
do {
4354+
if (breaks && r_cons_is_breaked (core->cons)) {
4355+
break;
4356+
}
43504357
repeat--;
43514358
const int p_bits = core->rasm->config->bits / 8;
43524359
#if 0
@@ -4404,6 +4411,9 @@ static void cmd_print_pv(RCore *core, const char *input, bool useBytes) {
44044411
break;
44054412
}
44064413
} while (repeat > 0);
4414+
if (breaks) {
4415+
r_cons_break_pop (core->cons);
4416+
}
44074417
free (heaped_block);
44084418
break;
44094419
}

0 commit comments

Comments
 (0)