fix integer overflow in midi parser sample count calculation (bug #200) #220
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes the 'impossibly long duration with crafted midi file' issue
as reported in bug #200. Midi file to test:
https://github.com/SegfaultMasters/covering360/raw/master/wildmidi/1_hang_main_00
Notes:
About arbitrary upper bounds for unacceptable delta (as noted in impossibly long duration with crafted midi file #200):
I changed the smallest_delta initializer from 0xffffffff to 0x7fffffff
i.e. I decided to use INT32_MAX instead of UINT32_MAX as a reasonable
upper bound. Rest of the integer overflow checks rely on multiplication
errors against INT32_MAX.
Overflow location was discovered when playing with clang's undefined
behavior sanitizer.
This does not do anything about the issue reported at bug issue with MIDI_0088.MID and MIDI_0089.HMI from Daggerfall #176.
Comments? @chrisisonwildcode, what do you say?
Please review thoroughly. I'm willing to revise according to critisisms.