mirror of
https://github.com/ringtailsoftware/uvm32.git
synced 2026-06-05 22:43:39 +00:00
Add test of reading cstring syscall argument which never terminates before hitting end of ram
This commit is contained in:
parent
b1b4cbf583
commit
0018bdd249
4 changed files with 31 additions and 0 deletions
|
|
@ -42,6 +42,11 @@ void syscall_gh_test(void) {
|
|||
syscall((uint32_t)SYSCALL_H, (uint32_t)buf, 32);
|
||||
}
|
||||
|
||||
void syscall_i_test(void) {
|
||||
char *p = "hello"; // runner will overwrite memory
|
||||
syscall((uint32_t)SYSCALL_I, (uint32_t)p, 0);
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
switch(syscall(SYSCALL_PICKTEST, 0, 0)) {
|
||||
case SYSCALL_A:
|
||||
|
|
@ -62,6 +67,9 @@ void main(void) {
|
|||
case SYSCALL_G:
|
||||
syscall_gh_test();
|
||||
break;
|
||||
case SYSCALL_I:
|
||||
syscall_i_test();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,4 +13,5 @@
|
|||
#define SYSCALL_F SYSCALL_BASE+6
|
||||
#define SYSCALL_G SYSCALL_BASE+7
|
||||
#define SYSCALL_H SYSCALL_BASE+8
|
||||
#define SYSCALL_I SYSCALL_BASE+9
|
||||
|
||||
|
|
|
|||
|
|
@ -169,3 +169,24 @@ void test_syscall_args_buf_pass(void) {
|
|||
}
|
||||
}
|
||||
|
||||
void test_syscall_args_string_never_terminates(void) {
|
||||
// run the vm
|
||||
uvm32_run(&vmst, &evt, 1000);
|
||||
// check for picktest syscall
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_PICKTEST);
|
||||
uvm32_arg_setval(&vmst, &evt, RET, SYSCALL_I);
|
||||
|
||||
uvm32_run(&vmst, &evt, 1000);
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_SYSCALL);
|
||||
TEST_ASSERT_EQUAL(evt.data.syscall.code, SYSCALL_I);
|
||||
// To ensure c string read goes off end looking for termination...
|
||||
memset(vmst._memory, 0xFF, UVM32_MEMORY_SIZE);
|
||||
TEST_ASSERT_EQUAL(0, strlen(uvm32_arg_getcstr(&vmst, &evt, ARG0)));
|
||||
|
||||
// check for error state
|
||||
uvm32_run(&vmst, &evt, 100);
|
||||
TEST_ASSERT_EQUAL(evt.typ, UVM32_EVT_ERR);
|
||||
TEST_ASSERT_EQUAL(evt.data.err.errcode, UVM32_ERR_MEM_RD);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue