Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sa2.cpp: Add missing checks in load()
The number of patterns, order length, and restart position are read from the file and used without checking. Add a check that rejects the file if these values anr not in the expected range to avoid OOB accesses or other unwanted behavior later. Also the track data is read until the end of the file, possibly overflowing the tracks array. Add checks to stop reading when the allocated number of patterns is filled. These changes fix crashes in rewind() for the follwing fuzzing samples: i-110_049.sa2, i-110_050.sa2, i-110_067.sat, i-110_081.sa2, i-110_082.sa2, i-110_106.sat, i-110_134.sat, i-110_140.sat, i-110_142.sat, i-110_148.sa2, i-110_150.sa2, i-110_162.sa2, i-110_163.sa2, i-110_167.sa2, i-110_197.sa2, and a crash in load() for sample i-110_149.sa2. Bug: adplug#110
- Loading branch information