Repository navigation
Commit 13510c7
gh-158928: Fix overflow in bytearray.__init__ from an iterator
Passing an iterator to `bytearray.__init__` didn't take into account
that iterating that iterator could modify the bytearray position and
`ob_start`. When that happened the iterator would write beyond the end
of the allocation.
Update the "enough space" check to account for `ob_start`. The
assignment always included it. Add an assert after append that the
offsets line up as expected.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent 978a8be commit 13510c7
3 files changed
Lines changed: 31 additions & 4 deletions
File tree
- Lib/test
- Misc/NEWS.d/next/Security
- Objects
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2085 | 2085 | | |
2086 | 2086 | | |
2087 | 2087 | | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
2088 | 2104 | | |
2089 | 2105 | | |
2090 | 2106 | | |
| |||
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1158 | 1158 | | |
1159 | 1159 | | |
1160 | 1160 | | |
1161 | | - | |
| 1161 | + | |
1162 | 1162 | | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
1163 | 1166 | | |
1164 | | - | |
1165 | | - | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
1166 | 1172 | | |
1167 | 1173 | | |
1168 | 1174 | | |
1169 | | - | |
| 1175 | + | |
1170 | 1176 | | |
| 1177 | + | |
1171 | 1178 | | |
| 1179 | + | |
| 1180 | + | |
1172 | 1181 | | |
1173 | 1182 | | |
1174 | 1183 | | |
| |||
0 commit comments