Skip to content

Commit

Permalink
Fix offset error
Browse files Browse the repository at this point in the history
  • Loading branch information
XuJiandong committed Apr 9, 2024
1 parent 8765d62 commit f3d0bfd
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
3 changes: 0 additions & 3 deletions script/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,6 @@ where
.store64(&length_addr, &actual_length)?;
machine.machine.set_register(A0, SUCCESS as u64);
} else {
// TODO: in the previous convention
// https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0009-vm-syscalls/0009-vm-syscalls.md#partial-loading
// this will load data in to address 0 without notice. It is now marked as an error.
machine.machine.set_register(A0, INDEX_OUT_OF_BOUND as u64);
}
continue;
Expand Down
Binary file modified script/testdata/spawn_fuzzing
Binary file not shown.
3 changes: 3 additions & 0 deletions script/testdata/spawn_fuzzing.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,23 @@ int extract_command(Data* data, Command* cmd) {
if (id > 250) {
cmd->id = SyscallClose;
cmd->fd_index = (size_t)(id % 2);
data->offset += 1;
} else if (id > 128) {
if ((data->offset + 7) > data->total_size) {
return -1;
}
cmd->id = SyscallRead;
memcpy(&cmd->buf_ptr, &data->ptr[data->offset + 1], 3);
memcpy(&cmd->len_ptr, &data->ptr[data->offset + 4], 3);
data->offset += 7;
} else {
if ((data->offset + 7) > data->total_size) {
return -1;
}
cmd->id = SyscallWrite;
memcpy(&cmd->buf_ptr, &data->ptr[data->offset + 1], 3);
memcpy(&cmd->len_ptr, &data->ptr[data->offset + 4], 3);
data->offset += 7;
}
return 0;
}
Expand Down

0 comments on commit f3d0bfd

Please sign in to comment.