Skip to content

Commit eabdd9e

Browse files
authored
Merge pull request #825 from crytic/restructure-test-folder
Restructure test folder
2 parents 0c174ef + 1782a76 commit eabdd9e

File tree

533 files changed

+130392
-4887
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

533 files changed

+130392
-4887
lines changed
File renamed without changes.
Lines changed: 198 additions & 198 deletions
Large diffs are not rendered by default.
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
pragma experimental ABIEncoderV2;
2+
3+
contract A {
4+
5+
struct S {
6+
uint i;
7+
}
8+
9+
uint[2][3] bad_arr = [[1, 2], [3, 4], [5, 6]];
10+
uint[3] good_arr = [1, 2, 3];
11+
S[3] s;
12+
13+
event event1_bad(uint[2][3] bad_arr);
14+
event event1_good(uint[3] good_arr);
15+
event event2_bad(S[3] s);
16+
17+
function bad0_external(uint [2][3] calldata arr1) external {
18+
}
19+
20+
/* Array of arrays passed to an external function is vulnerable */
21+
function bad0() public {
22+
this.bad0_external(bad_arr);
23+
}
24+
25+
function bad1_external (S[3] calldata s1) external {
26+
}
27+
28+
/* Array of structs passed to an external function is vulnerable */
29+
function bad1 (S[3] memory s1) public {
30+
this.bad1_external(s);
31+
}
32+
33+
/* Array of arrays passed to abi.encode is vulnerable */
34+
function bad2() public {
35+
bytes memory b = abi.encode(bad_arr);
36+
}
37+
38+
/* Array of structs passed to abi.encode is vulnerable */
39+
function bad3() public {
40+
bytes memory b = abi.encode(s);
41+
}
42+
43+
/* Array of arrays passed to an event emit is vulnerable */
44+
function bad4() public {
45+
emit event1_bad(bad_arr);
46+
}
47+
48+
/* Array of structs passed to an event emit is vulnerable */
49+
function bad5() public {
50+
emit event2_bad(s);
51+
}
52+
53+
function good0_public (uint[2][3] memory arr1) public {
54+
}
55+
56+
/* Array of arrays passed to a public function is benign */
57+
function good0() public {
58+
good0_public(bad_arr);
59+
}
60+
61+
function good1_public (S[3] memory s1) public {
62+
}
63+
64+
/* Array of structs passed to a public function is benign */
65+
function good1 (S[3] memory s1) public {
66+
good1_public(s);
67+
}
68+
69+
/* Array of arrays in-memory passed to abi.encode is benign */
70+
function good2() public {
71+
uint8 [2][3] memory bad_arr_mem = [[1, 2], [3, 4], [5, 6]];
72+
bytes memory b = abi.encode(bad_arr_mem);
73+
}
74+
75+
/* Array of structs in-memory passed to abi.encode is benign */
76+
function good3() public {
77+
S[3] memory s_mem;
78+
bytes memory b = abi.encode(s_mem);
79+
}
80+
81+
function good4_external(uint[3] calldata arr1) external {
82+
}
83+
84+
/* Array of elementary types passed to external function is benign */
85+
function good4() public {
86+
this.good4_external(good_arr);
87+
}
88+
89+
/* Array of elementary types passed to abi.encode is benign */
90+
function good5() public {
91+
bytes memory b = abi.encode(good_arr);
92+
}
93+
94+
/* Array of elementary types passed to event emit is benign */
95+
function good6() public {
96+
emit event1_good(good_arr);
97+
}
98+
99+
}

0 commit comments

Comments
 (0)