Commit 8af47cb
committed
security: ByteBuffer: fix heap buffer overflow on slice realloc
Motivation:
ByteBuffer had a very bad (exploitable!) security vulnerability if the
following conditions are all true:
- user writes to a ByteBuffer which is a slice (slice.lowerBound != 0)
- the slice is uniquely referenced (ie. the buffer that it was sliced
from is gone)
- the write triggers a re-allocation
Then the slice is actually _larger_ than the overall available capacity
so another write to said ByteBuffer could end up out of bounds.
Modifications:
- fixed slice reallocation
Result:
- fixed security vulnerability1 parent 3275ff7 commit 8af47cb
File tree
3 files changed
+61
-19
lines changed- Sources/NIO
- Tests/NIOTests
3 files changed
+61
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
220 | | - | |
221 | | - | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
222 | 223 | | |
223 | | - | |
| 224 | + | |
224 | 225 | | |
225 | | - | |
| 226 | + | |
226 | 227 | | |
227 | 228 | | |
228 | 229 | | |
| |||
267 | 268 | | |
268 | 269 | | |
269 | 270 | | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
279 | 280 | | |
280 | | - | |
| 281 | + | |
| 282 | + | |
281 | 283 | | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
286 | 289 | | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
287 | 293 | | |
288 | 294 | | |
289 | 295 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
97 | 131 | | |
98 | 132 | | |
99 | 133 | | |
| |||
491 | 525 | | |
492 | 526 | | |
493 | 527 | | |
494 | | - | |
| 528 | + | |
495 | 529 | | |
496 | 530 | | |
497 | 531 | | |
| |||
0 commit comments