-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
formats/cassimg.cpp: Fixed bad image crash in tap format (MT8952) #13294
base: master
Are you sure you want to change the base?
Conversation
src/lib/formats/cassimg.h
Outdated
@@ -127,6 +127,7 @@ class cassette_image | |||
uint32_t sample_frequency = 0; | |||
int header_samples = 0; | |||
int trailer_samples = 0; | |||
int (*fill_wave_ext)(int16_t *, int, const uint8_t *, int) = nullptr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively I can change signature for all existing fill_wave
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm waiting for consensus. Have this ^^^ implemented locally or can easily refactor to loading error without crash if you insist.
Can you explain what the issue is, how it happens, and what this change is supposed to do to deal with it? Alternatively, would it be better to just reject these bad tape images? Trying to “fix” or gracefully handle bad input has been a constant source of bugs over the years, which is why software is increasingly moving to an approach of rejecting bad input outright. |
Has MAME been doing anything specific in this direction, or is it just a trend witnessed elsewhere? |
It's pretty much explained in the deleted comment. Rejecting this images is the possibility, but with this change we are in better shape, as we can try to convert as much as we can and potentially that will (and proven "is") be enough. |
Yes, MAME is a lot better at rejecting rather than crashing on thing like bad ZIP, PNG and ICO files. There’s also more error checking in cartridge loading, etc. to reject invalid input. But it’s a trend in software in general, as the realisation has set in that “be liberal in what you accept and strict in what you produce” has cause more problems than it solves. In particular, there’s inconsistency in how different software interprets the same invalid input, and all manner of bugs caused by the complexity of trying to do something useful with invalid input. |
Another though: |
Maybe we can osd warning about wrong image. Not sure if a lot of people cares about logs - that will reduce false bugrepors. |
What about updating the ones which are still using legacy cassette routines, to use the newer routines? I did this for the Heath H8/H88 file (although my PR is still waiting for a review - #13250). This removes the need to determine the size up front (the base routines resize as needed). |
I hope this time the fix is more solid and non-destructive