Adds appropriate checks/guards around all the untrusted parameters which are used for reading from memory.
Stride calculation from MSDN
- All the crashing files within the bug have been checked to not causes crashes any longer
- A handful of correct .bmp were validated: 3 different files at each of 1, 4, 8, 24, 32 bpp depth along with a random variety of other 24 bpp files (around 20 in total).
- ~280 million iterations of fuzzing using AFL were completed with 0 crashes. The old code experienced several dozen crashes in first minutes of running
- It would be good to have another set of folks try some .bmps they have lying around
- Unfortunately, I could not find software that would write out _uncompressed_ 16 bpp images (565 format)