Commit cbf10bc
authored
[lld-macho] Avoid infinite recursion when parsing corrupted export tries (#152569)
If an export trie is encoded incorrectly, and one of the children
offsets points back to one of the nodes earlier in the serialization,
the current code will end up in an infinite recursion, and eventually
fail exhausting the available memory.
The failure can be avoided if, before recursing, one checks that the
offset is valid, that is, that the offset is beyond the current
position. This is similar to a check done by llvm-objdump which reports
the trie being corrupted.1 parent 1532116 commit cbf10bc
File tree
5 files changed
+43
-17
lines changed- lld
- MachO
- test/MachO/invalid
- Inputs
5 files changed
+43
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
296 | 297 | | |
297 | 298 | | |
298 | 299 | | |
299 | | - | |
300 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
301 | 303 | | |
302 | | - | |
| 304 | + | |
| 305 | + | |
303 | 306 | | |
304 | | - | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
305 | 311 | | |
| 312 | + | |
306 | 313 | | |
307 | 314 | | |
308 | 315 | | |
309 | 316 | | |
310 | 317 | | |
311 | 318 | | |
312 | 319 | | |
313 | | - | |
| 320 | + | |
| 321 | + | |
314 | 322 | | |
315 | | - | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
316 | 327 | | |
317 | 328 | | |
318 | 329 | | |
| |||
331 | 342 | | |
332 | 343 | | |
333 | 344 | | |
334 | | - | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
335 | 348 | | |
| 349 | + | |
| 350 | + | |
336 | 351 | | |
337 | 352 | | |
338 | | - | |
339 | | - | |
| 353 | + | |
| 354 | + | |
340 | 355 | | |
341 | 356 | | |
342 | 357 | | |
343 | | - | |
| 358 | + | |
344 | 359 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
| 44 | + | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1789 | 1789 | | |
1790 | 1790 | | |
1791 | 1791 | | |
1792 | | - | |
1793 | | - | |
1794 | | - | |
1795 | | - | |
1796 | | - | |
1797 | | - | |
| 1792 | + | |
| 1793 | + | |
| 1794 | + | |
| 1795 | + | |
| 1796 | + | |
| 1797 | + | |
| 1798 | + | |
1798 | 1799 | | |
1799 | 1800 | | |
1800 | 1801 | | |
| |||
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
0 commit comments