Commit 3f082c5
committed
libmodplug: Fix misc. loader crashes and leaks found by libFuzzer:
Patchset by Alice Rowan: Konstanty/libmodplug#58
* AMF (DSMI): fix out-of-bounds reads caused by missing order list
bounds checks.
* DBM: fix leaks caused by duplicate instrument chunks being loaded.
* FAR: fix out-of-bounds reads due to not correctly bounding the
maximum pattern read size.
* IT: fix out-of-bounds reads in the IT sample decompressors caused
by allowing ITReadBits to read past the end of the buffer.
* MED: fix out-of-bounds reads due to a faulty MMD2PLAYSEQ bounds check.
* MED: fix out-of-bounds reads due to bad sample bounding.
* MED: fix out-of-bounds reads due to bad block name bounding (and
potential missing nul terminators).
* OKT: fix out-of-bounds reads due to incorrect OKTSAMPLE bounding.
* OKT: fix out-of-bounds reads due to bad chunk header and order
list bounding.
* OKT: fix playback errors caused by skipping the first two orders in
the order list.
* S3M: fix out-of-bounds reads due to missing order list bounds check.
* S3M: fix out-of-bounds reads due to missing offset list bounds check.
* S3M: fix out-of-bounds reads due to missing panning table check.
* STM: fix pattern leaks and pattern size corruption caused by missing
MAX_PATTERNS check.
* ULT: fix out-of-bounds reads due to incorrect event bounding.
* WAV: fix out-of-bounds reads due to not bounds checking the fmt chunk.
* WAV: fix hangs caused by missing chunk length bounds check.
* WAV: constify pointers derived from lpStream.
* XM: fix out-of-bounds reads due to broken XMSAMPLEHEADER check.
* XM: fix out-of-bounds reads due to missing pattern data checks.
* XM: fix slow loads caused by bad bounding in instrument/sample
loops, add other various missing bounds checks.
- Fix AMS loader crash and slow load bugs found by libFuzzer:
* AMS: fix AMS out-of-bounds reads due to missing song comments checks.
* AMS: fix AMS out-of-bounds reads due to missing order list check.
* AMS: fix AMS out-of-bounds reads due to missing pattern/track checks.
* AMS: fix AMS2 out-of-bounds reads due to missing/broken instrument
and envelope bounds checks.
* AMS: fix AMS2 out-of-bounds reads due to missing sample bounds checks.
* AMS: fix ReadSample out-of-bounds reads due to overflow in packed
size bounds check.
* AMS: fix AMSUnpack out-of-bounds reads due to missing RLE unpacking
bounds checks.
* AMS: reduce AMSUnpack slow loads by rejecting samples with truncated
or invalid RLE.
* AMS: reduce AMSUnpack slow loads by shrinking samples if their packed
size couldn't possibly store them.
* AMS: constify pointers derived from lpStream.
- Fix DMF loader crash/hang/slow load bugs found by libFuzzer:
* DMF: fix faulty bounds checks for INFO, SEQU, and SMPI chunks.
* DMF: add numerous missing bounds checks for patterns and track data.
* DMF: fix out-of-bounds reads caused by missing sample bounds check.
* DMF: fix hangs caused by duplicate PATT chunks.
* DMF: fix sample leaks caused by duplicate SMPD chunks.
* DMF: fix slow loads caused by missing EOF check in DMFUnpack.
* DMF: constify pointers derived from lpStream.
- Fix MDL loader crash bugs found by libFuzzer:
* MDL: fix out-of-bounds reads due to missing info chunk bounds check.
* MDL: fix out-of-bounds reads due to a missing bounds check when
loading instruments.
* MDL: fix out-of-bounds reads and other bugs due to bad envelope
bounding and missing duplicate envelope chunk checks.
* MDL: fix out-of-bounds reads due to broken track bounds checks.
- Fix MT2 loader crashes and hangs found by libFuzzer:
* MT2: fix out-of-bounds reads due to missing nDrumDataLen check.
* MT2: fix out-of-bounds reads due to missing pattern/track checks.
* MT2: fix out-of-bounds reads due to broken/nonsensical instrument
bounds checks.
* MT2: fix out-of-bounds reads due to missing sample data length
bounds check.
* MT2: fix out-of-bounds reads due to bad checks on group structs.
* MT2: fix hangs caused by overflows preventing the data chunk size
bounds check from working.
* MT2: constify pattern data pointer derived from lpStream.
- Fix PSM loader crash bugs found by libFuzzer:
* PSM: fix out-of-bounds reads due to dereferencing lpStream before
any bounds checks.
* PSM: fix out-of-bounds reads due to reading pPsmPat.data from the
stack instead of the input buffer.
* PSM: fix out-of-bounds reads due to invalid samples in patterns.
* PSM: fix missing pattern length byte-swapping.
* PSM: constify pattern data pointer derived from lpStream.1 parent 6c09865 commit 3f082c5
16 files changed
Lines changed: 236 additions & 105 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
| 302 | + | |
302 | 303 | | |
303 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
304 | 308 | | |
305 | 309 | | |
306 | 310 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
43 | 44 | | |
44 | | - | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | | - | |
| 48 | + | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
| |||
60 | 61 | | |
61 | 62 | | |
62 | 63 | | |
63 | | - | |
| 64 | + | |
64 | 65 | | |
65 | 66 | | |
66 | 67 | | |
| |||
106 | 107 | | |
107 | 108 | | |
108 | 109 | | |
| 110 | + | |
109 | 111 | | |
110 | 112 | | |
111 | | - | |
| 113 | + | |
112 | 114 | | |
113 | 115 | | |
114 | 116 | | |
115 | 117 | | |
116 | 118 | | |
| 119 | + | |
117 | 120 | | |
118 | 121 | | |
119 | 122 | | |
| |||
125 | 128 | | |
126 | 129 | | |
127 | 130 | | |
128 | | - | |
| 131 | + | |
129 | 132 | | |
130 | 133 | | |
131 | 134 | | |
| |||
141 | 144 | | |
142 | 145 | | |
143 | 146 | | |
| 147 | + | |
144 | 148 | | |
145 | 149 | | |
146 | 150 | | |
| |||
149 | 153 | | |
150 | 154 | | |
151 | 155 | | |
| 156 | + | |
152 | 157 | | |
153 | 158 | | |
154 | 159 | | |
| |||
166 | 171 | | |
167 | 172 | | |
168 | 173 | | |
| 174 | + | |
169 | 175 | | |
170 | 176 | | |
171 | 177 | | |
| |||
208 | 214 | | |
209 | 215 | | |
210 | 216 | | |
| 217 | + | |
211 | 218 | | |
212 | 219 | | |
213 | 220 | | |
| |||
225 | 232 | | |
226 | 233 | | |
227 | 234 | | |
228 | | - | |
| 235 | + | |
| 236 | + | |
229 | 237 | | |
230 | 238 | | |
231 | 239 | | |
| |||
288 | 296 | | |
289 | 297 | | |
290 | 298 | | |
291 | | - | |
292 | 299 | | |
293 | 300 | | |
294 | 301 | | |
295 | 302 | | |
296 | 303 | | |
297 | 304 | | |
298 | 305 | | |
299 | | - | |
| 306 | + | |
300 | 307 | | |
301 | 308 | | |
302 | 309 | | |
| |||
317 | 324 | | |
318 | 325 | | |
319 | 326 | | |
| 327 | + | |
320 | 328 | | |
321 | 329 | | |
322 | | - | |
| 330 | + | |
323 | 331 | | |
324 | | - | |
325 | | - | |
| 332 | + | |
| 333 | + | |
326 | 334 | | |
327 | 335 | | |
| 336 | + | |
328 | 337 | | |
329 | 338 | | |
| 339 | + | |
330 | 340 | | |
331 | 341 | | |
| 342 | + | |
332 | 343 | | |
333 | 344 | | |
334 | 345 | | |
| |||
361 | 372 | | |
362 | 373 | | |
363 | 374 | | |
| 375 | + | |
364 | 376 | | |
365 | 377 | | |
366 | 378 | | |
| |||
370 | 382 | | |
371 | 383 | | |
372 | 384 | | |
| 385 | + | |
373 | 386 | | |
374 | 387 | | |
| 388 | + | |
375 | 389 | | |
| 390 | + | |
376 | 391 | | |
377 | 392 | | |
378 | | - | |
| 393 | + | |
379 | 394 | | |
380 | 395 | | |
381 | 396 | | |
| |||
502 | 517 | | |
503 | 518 | | |
504 | 519 | | |
| 520 | + | |
505 | 521 | | |
506 | 522 | | |
507 | 523 | | |
508 | 524 | | |
509 | | - | |
| 525 | + | |
510 | 526 | | |
511 | 527 | | |
512 | 528 | | |
513 | 529 | | |
514 | 530 | | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
515 | 554 | | |
516 | 555 | | |
517 | 556 | | |
518 | 557 | | |
519 | 558 | | |
520 | 559 | | |
521 | 560 | | |
522 | | - | |
| 561 | + | |
523 | 562 | | |
524 | 563 | | |
525 | 564 | | |
| |||
530 | 569 | | |
531 | 570 | | |
532 | 571 | | |
| 572 | + | |
533 | 573 | | |
534 | 574 | | |
535 | 575 | | |
| 576 | + | |
536 | 577 | | |
537 | 578 | | |
538 | 579 | | |
| |||
542 | 583 | | |
543 | 584 | | |
544 | 585 | | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
545 | 592 | | |
546 | 593 | | |
547 | 594 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
134 | 137 | | |
135 | 138 | | |
136 | 139 | | |
| |||
227 | 230 | | |
228 | 231 | | |
229 | 232 | | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
230 | 236 | | |
231 | 237 | | |
232 | 238 | | |
| |||
0 commit comments