Commit ac3bd35
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 eb0342b commit ac3bd35
20 files changed
Lines changed: 325 additions & 166 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
315 | 315 | | |
316 | 316 | | |
317 | 317 | | |
| 318 | + | |
318 | 319 | | |
319 | 320 | | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
320 | 324 | | |
321 | 325 | | |
322 | 326 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
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 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
66 | | - | |
| 67 | + | |
67 | 68 | | |
68 | 69 | | |
69 | 70 | | |
| |||
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
| 119 | + | |
118 | 120 | | |
119 | 121 | | |
120 | | - | |
| 122 | + | |
121 | 123 | | |
122 | 124 | | |
123 | 125 | | |
| |||
127 | 129 | | |
128 | 130 | | |
129 | 131 | | |
| 132 | + | |
130 | 133 | | |
131 | 134 | | |
132 | 135 | | |
| |||
138 | 141 | | |
139 | 142 | | |
140 | 143 | | |
141 | | - | |
| 144 | + | |
142 | 145 | | |
143 | 146 | | |
144 | 147 | | |
| |||
154 | 157 | | |
155 | 158 | | |
156 | 159 | | |
| 160 | + | |
157 | 161 | | |
158 | 162 | | |
159 | 163 | | |
| |||
162 | 166 | | |
163 | 167 | | |
164 | 168 | | |
| 169 | + | |
165 | 170 | | |
166 | 171 | | |
167 | 172 | | |
| |||
179 | 184 | | |
180 | 185 | | |
181 | 186 | | |
| 187 | + | |
182 | 188 | | |
183 | 189 | | |
184 | 190 | | |
| |||
221 | 227 | | |
222 | 228 | | |
223 | 229 | | |
| 230 | + | |
224 | 231 | | |
225 | 232 | | |
226 | 233 | | |
| |||
238 | 245 | | |
239 | 246 | | |
240 | 247 | | |
241 | | - | |
| 248 | + | |
| 249 | + | |
242 | 250 | | |
243 | 251 | | |
244 | 252 | | |
| |||
301 | 309 | | |
302 | 310 | | |
303 | 311 | | |
304 | | - | |
305 | 312 | | |
306 | 313 | | |
307 | 314 | | |
308 | 315 | | |
309 | 316 | | |
310 | 317 | | |
311 | 318 | | |
312 | | - | |
| 319 | + | |
313 | 320 | | |
314 | 321 | | |
315 | 322 | | |
| |||
335 | 342 | | |
336 | 343 | | |
337 | 344 | | |
| 345 | + | |
338 | 346 | | |
339 | | - | |
| 347 | + | |
340 | 348 | | |
341 | | - | |
| 349 | + | |
342 | 350 | | |
343 | | - | |
344 | | - | |
| 351 | + | |
| 352 | + | |
345 | 353 | | |
346 | 354 | | |
| 355 | + | |
347 | 356 | | |
348 | 357 | | |
| 358 | + | |
349 | 359 | | |
350 | 360 | | |
| 361 | + | |
351 | 362 | | |
352 | 363 | | |
353 | 364 | | |
| |||
387 | 398 | | |
388 | 399 | | |
389 | 400 | | |
| 401 | + | |
390 | 402 | | |
391 | 403 | | |
392 | 404 | | |
| |||
396 | 408 | | |
397 | 409 | | |
398 | 410 | | |
| 411 | + | |
399 | 412 | | |
400 | 413 | | |
| 414 | + | |
401 | 415 | | |
402 | 416 | | |
403 | 417 | | |
404 | 418 | | |
405 | 419 | | |
| 420 | + | |
406 | 421 | | |
407 | 422 | | |
408 | | - | |
| 423 | + | |
409 | 424 | | |
410 | 425 | | |
411 | 426 | | |
| |||
545 | 560 | | |
546 | 561 | | |
547 | 562 | | |
| 563 | + | |
548 | 564 | | |
549 | 565 | | |
550 | 566 | | |
551 | 567 | | |
552 | | - | |
| 568 | + | |
553 | 569 | | |
554 | 570 | | |
555 | 571 | | |
556 | 572 | | |
557 | 573 | | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
558 | 597 | | |
559 | 598 | | |
560 | 599 | | |
561 | 600 | | |
562 | 601 | | |
563 | 602 | | |
564 | 603 | | |
565 | | - | |
| 604 | + | |
566 | 605 | | |
567 | 606 | | |
568 | 607 | | |
| |||
573 | 612 | | |
574 | 613 | | |
575 | 614 | | |
| 615 | + | |
576 | 616 | | |
577 | 617 | | |
578 | 618 | | |
| 619 | + | |
579 | 620 | | |
580 | 621 | | |
581 | 622 | | |
| |||
585 | 626 | | |
586 | 627 | | |
587 | 628 | | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
588 | 635 | | |
589 | 636 | | |
590 | 637 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
139 | 142 | | |
140 | 143 | | |
141 | 144 | | |
| |||
239 | 242 | | |
240 | 243 | | |
241 | 244 | | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
242 | 248 | | |
243 | 249 | | |
244 | 250 | | |
| |||
0 commit comments