Skip to content

PacketBuffer accepts bigger packets than it should #57

@mzero

Description

@mzero

While it is hard to discern, there is a limit in CoreMIDI on the size of a packet in a MIDIPacketList. The docs only say:

The maximum size of a packet list is 65536 bytes. Large sysex messages must be sent in smaller packet lists.

Note also that the length field of MIDIPacket is only a UInt16. The actual packet size limit is smaller than that, after subtracting out the MIDIPacket and MIDIPacketList overheads from the max size of the list.


PacketBuffer will attempt to create a MIDIPacketList with a single MIDIPacket, large enough to accommodate however big a data object is passed in. If used with very large messages (think 80k sysex!) - PacketBuffer will build the structures, but the resulting thing will be corrupted, as it can't really hold a message that big.

PacketBuffer should at least make it clear in the docs that there is a limit on size.


How did I find this? I'm sending 80k sysexs (to control a synth) from a WebMIDI app.... and in Firefox on Mac it crashes the browser completely and instantly! I don't know who to blame for the crash... but the 80k byte array gets passed:

JavaScript -> Firefox/Gekko's C++ code -> Firefox/Gekkot's Rust crate midir_impl -> Boodlnagg's Rust midir package -> coremidi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions