Skip to content

Commit

Permalink
Fixed potental out of bound memory access in example linux PEEK sysca…
Browse files Browse the repository at this point in the history
…ll. Thanks cde!
  • Loading branch information
zevv committed Apr 2, 2023
1 parent ea4226e commit fc6c1c0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/linux/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ zf_input_state zf_host_sys(zf_syscall_id id, const char *input)

case ZF_SYSCALL_TELL: {
zf_cell len = zf_pop();
void *buf = (uint8_t *)zf_dump(NULL) + (int)zf_pop();
zf_cell addr = zf_pop();
if(addr >= ZF_DICT_SIZE - len) {
zf_abort(ZF_ABORT_OUTSIDE_MEM);
}
void *buf = (uint8_t *)zf_dump(NULL) + (int)addr;
(void)fwrite(buf, 1, len, stdout);
fflush(stdout); }
break;
Expand Down

0 comments on commit fc6c1c0

Please sign in to comment.