-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[MU3] Fix 310158: Don't null terminate MIDI sequence track name messages #7003
Conversation
the mtests are not happy, which I guess is understandable, but needs fixing anyway? I don't quite understand why the vtests failed, but can't imagine this to be your (PR's) fault. |
It looks like the layout code for 3.x has been changed since I opened the PR, but since my commits don't change these, I believe they could be merged without problems. I could also pull in the 3.x branch if that makes more sense. |
As far as I can tell the build in CI is always done against the then latest commit. |
Remove MIDI sequence track name null terminators
audio/exports/exportmidi.cpp
Outdated
@@ -90,7 +90,7 @@ void ExportMidi::writeHeader() | |||
Staff* staff = cs->staff(staffIdx); | |||
|
|||
QByteArray partName = staff->partName().toUtf8(); | |||
int len = partName.length() + 1; | |||
int len = partName.length(); |
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.
This line was correct. An increasing of the length must be here.
See Qt's documentation: https://doc.qt.io/qt-5/qbytearray.html#data
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.
Since we're doing a memcpy
instead of a strcpy
, I don't think the + 1
is necessary.
I would fix it here. MuseScore/audio/midi/midifile.cpp Lines 138 to 139 in 8c98ded
|
I feel like it makes sense to store the non-null-terminated string as the data for the event since it's the actual data. Fixing it in MuseScore/audio/midi/midifile.cpp Lines 138 to 139 in 8c98ded
probably works, but then we have to do a special check for a track name message. We could also change MuseScore/audio/exports/exportmidi.cpp Line 102 in 8c98ded
|
But creation of char string without a null termination is very crashable way. Line 205 in 6e28741
It's good to fix it where file are saved instead of creation of broken MIDI events. For an example, midi import adds null termination while reading a file. |
Please squash the commits |
audio/midi/midifile.cpp
Outdated
@@ -135,8 +135,14 @@ void MidiFile::writeEvent(const MidiEvent& event) | |||
case ME_META: | |||
put(ME_META); | |||
put(event.metaType()); | |||
putvl(event.len()); | |||
write(event.edata(), event.len()); | |||
if (event.metaType() == META_TRACK_NAME) { |
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.
Why track name type only? What about the other text types (0x01 - 0x07)?
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.
Because the issue is about track name only I guess, "Sequence Track Name MIDI messages wrongly null-terminated"
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.
Obviously, we have to check out what the MIDI standard says here.
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.
In https://www.midi.org/component/edocman/rp-001-v1-0-standard-midi-files-specification-96-1-4-pdf/fdocument?Itemid=9999, it looks like types 0x01–0x07 are text types, and https://www.midi.org/component/edocman/smf-device-name-and-program-name-meta-events/fdocument?Itemid=9999 adds 0x08 and 0x09. In
Lines 77 to 81 in 6e28741
META_TITLE = 0x10, // mscore extension | |
META_SUBTITLE = 0x11, // mscore extension | |
META_COMPOSER = 0x12, // mscore extension | |
META_TRANSLATOR = 0x13, // mscore extension | |
META_POET = 0x14, // mscore extension |
This problem resurfaced in the current stable and nightly build.
It outputs something like |
Of course it does, the changes from this PR haven't been merged into 3.x nor been ported/merged to master. The logs for the failing tests (vtests and mtest) have expired, are no longer available (as have the artifacts, so no way to test using those), so impossible to check what went wrong there, and so equally impossible to tell why they went wrong. Please squash the commits, Also better rebase the entire thing on top of the master branch, as there won't be any further 3.x release. The mtest failures are most probably due to the *-ref.mid files having been changed only after the 1st commit, which then later got reverted, and that after the 4th commit all text meta events are not null-terminated anymore. |
Port of PR musescore#7003 to the master branch
OK, I bit the bullet and ported it over to master (see PR #10374), was pretty easy and straight forward, esp. as none of the tests needed to get ported ;-) |
Port of PR #7003 to the master branch
I'd like to include this PR in my PR #9000, but can't seem to get the mtests to work, how would these *-ref.mid files need to get generated? |
Port of PR musescore#7003 resp. backport of PR musescore#10374
OK, I managed it, it is now part of PR #9000, As no further 3.x is planned and the changes are in master already too, I believe this PR here could/should get closed. |
Port of PR musescore#7003 resp. backport of PR musescore#10374
Port of PR musescore#7003 resp. backport of PR musescore#10374
Port of PR musescore#7003 resp. backport of PR musescore#10374
Port of PR musescore#7003 resp. backport of PR musescore#10374
Port of PR musescore#7003 resp. backport of PR musescore#10374
3.x is closed for any changes |
Port of PR musescore#7003 resp. backport of PR musescore#10374
Resolves: https://musescore.org/en/node/310158
This PR makes it so that the null terminator from a part's name is not copied.