diff --git a/script/src/verify/tests/ckb_latest/features_since_v2023.rs b/script/src/verify/tests/ckb_latest/features_since_v2023.rs index fac884e630..9355153830 100644 --- a/script/src/verify/tests/ckb_latest/features_since_v2023.rs +++ b/script/src/verify/tests/ckb_latest/features_since_v2023.rs @@ -1158,7 +1158,6 @@ proptest! { #[test] fn check_spawn_close_invalid_fd() { let result = simple_spawn_test("testdata/spawn_cases", &[12]); - println!("--- err: {:?}", result); assert_eq!(result.is_ok(), SCRIPT_VERSION == ScriptVersion::V2); } @@ -1221,3 +1220,15 @@ fn check_spawn_huge_swap() { assert!(result.is_err()) } } + +#[test] +fn check_spawn_invaild_index() { + let result = simple_spawn_test("testdata/spawn_cases", &[17]); + assert_eq!(result.is_ok(), SCRIPT_VERSION == ScriptVersion::V2); +} + +#[test] +fn check_spawn_index_out_of_bound() { + let result = simple_spawn_test("testdata/spawn_cases", &[18]); + assert_eq!(result.is_ok(), SCRIPT_VERSION == ScriptVersion::V2); +} diff --git a/script/testdata/spawn_cases b/script/testdata/spawn_cases index e26caac38c..7d4a305ff3 100755 Binary files a/script/testdata/spawn_cases and b/script/testdata/spawn_cases differ diff --git a/script/testdata/spawn_cases.c b/script/testdata/spawn_cases.c index 0af3f62769..ded149dacf 100644 --- a/script/testdata/spawn_cases.c +++ b/script/testdata/spawn_cases.c @@ -496,7 +496,7 @@ int parent_spawn_length_out_of_bound(uint64_t* pid) { const char* argv[] = {"", 0}; spawn_args_t spgs = {.argc = 1, .argv = argv, .process_id = pid, .inherited_fds = NULL}; - uint64_t offset = 1024 * 14; + uint64_t offset = 1024 * 15; uint64_t length = 1024; uint64_t bounds = (offset << 32) + length; @@ -507,6 +507,46 @@ int parent_spawn_length_out_of_bound(uint64_t* pid) { return err; } +int parent_invaild_index(uint64_t* pid) { + int err = 0; + const char* argv[] = {"", 0}; + uint64_t inherited_fds[11] = {0}; + for (size_t i = 0; i < 5; i++) { + err = ckb_pipe(&inherited_fds[i * 2]); + CHECK(err); + } + spawn_args_t spgs = {.argc = 1, + .argv = argv, + .process_id = pid, + .inherited_fds = inherited_fds}; + err = ckb_spawn(0xFFFFFFFFF, CKB_SOURCE_CELL_DEP, 0, 0, &spgs); + CHECK2(err == 1, -1); // INDEX_OUT_OF_BOUND + err = 0; + +exit: + return err; +} + +int parent_index_out_of_bound(uint64_t* pid) { + int err = 0; + const char* argv[] = {"", 0}; + uint64_t inherited_fds[11] = {0}; + for (size_t i = 0; i < 5; i++) { + err = ckb_pipe(&inherited_fds[i * 2]); + CHECK(err); + } + spawn_args_t spgs = {.argc = 1, + .argv = argv, + .process_id = pid, + .inherited_fds = inherited_fds}; + err = ckb_spawn(2, CKB_SOURCE_CELL_DEP, 0, 0, &spgs); + CHECK2(err == 1, -1); // INDEX_OUT_OF_BOUND + err = 0; + +exit: + return err; +} + int parent_entry(int case_id) { int err = 0; uint64_t pid = 0; @@ -544,6 +584,10 @@ int parent_entry(int case_id) { return parent_spawn_offset_out_of_bound(&pid); } else if (case_id == 16) { return parent_spawn_length_out_of_bound(&pid); + } else if (case_id == 17) { + return parent_invaild_index(&pid); + } else if (case_id == 18) { + return parent_index_out_of_bound(&pid); } else { CHECK2(false, -2); }