Skip to content
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

some midi file with long text events will cause app cracked #110

Open
594chendata opened this issue Apr 25, 2023 · 2 comments
Open

some midi file with long text events will cause app cracked #110

594chendata opened this issue Apr 25, 2023 · 2 comments

Comments

@594chendata
Copy link

I find MidiEvent::loadMidiEvent(),
int length = MidiFile::variableLengthvalue(content);
if (tempByte >= 0x01 && tempByte <= 0x07) {
...
wchar_t str[128] = L"";
for (int i = 0; i < length; i++) {
(*content) >> tempByte;
wchar_t temp[2] = { btowc(tempByte) };
wcsncat(str, temp, 1);
}
textEvent->setText(QString::fromWCharArray(str));
ok = true;
in a midi file, the 0xff event 01-07 format,the len field may >128,this cause array str exceeds the upper boundary and the application crashes.
I modified as the following, and it works well.
wchar_t * str = new wchar_t[length+1];
memset(str, 0, sizeof(wchar_t)
(length+1));
for (int i = 0; i < length; i++) {
(*content) >> tempByte;
wchar_t temp[2] = { btowc(tempByte) };
wcsncat(str, temp, 1);
}
textEvent->setText(QString::fromWCharArray(str));
*ok = true;
delete[] str;

@icebob
Copy link

icebob commented Jun 1, 2024

I have the same problem.

@594chendata Did you fork the repo with your fix?

@594chendata
Copy link
Author

594chendata commented Jun 4, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants