Commit 917c43b
authored
fix: prevent out-of-bounds write in derive_address (#2088)
The bounds check allowed seeds.len() == MAX_SEEDS, but the data array
is [MAX_SEEDS + 2] and needs to hold seeds + bump + program_id + PDA_MARKER
(3 extra items). This caused an OOB write at index MAX_SEEDS + 2 when
seeds.len() == MAX_SEEDS.
Changed check from > to >= MAX_SEEDS in both check_seeds() and derive_address().1 parent 8328855 commit 917c43b
1 file changed
Lines changed: 6 additions & 4 deletions
Lines changed: 6 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
39 | | - | |
| 38 | + | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
65 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
66 | 68 | | |
67 | 69 | | |
68 | 70 | | |
| |||
0 commit comments