]> Git Repo - J-linux.git/commitdiff
ALSA: line6: fix stack overflow in line6_midi_transmit
authorArtem Egorkine <[email protected]>
Sun, 25 Dec 2022 10:57:28 +0000 (12:57 +0200)
committerTakashi Iwai <[email protected]>
Mon, 26 Dec 2022 08:07:49 +0000 (09:07 +0100)
Correctly calculate available space including the size of the chunk
buffer. This fixes a buffer overflow when multiple MIDI sysex
messages are sent to a PODxt device.

Signed-off-by: Artem Egorkine <[email protected]>
Cc: <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Takashi Iwai <[email protected]>
sound/usb/line6/midi.c

index d52355de2bbc023a7268a3dcdf1539154c747619..0838632c788e4a120c50a20db56ff75d69e1ed77 100644 (file)
@@ -44,7 +44,8 @@ static void line6_midi_transmit(struct snd_rawmidi_substream *substream)
        int req, done;
 
        for (;;) {
-               req = min(line6_midibuf_bytes_free(mb), line6->max_packet_size);
+               req = min3(line6_midibuf_bytes_free(mb), line6->max_packet_size,
+                          LINE6_FALLBACK_MAXPACKETSIZE);
                done = snd_rawmidi_transmit_peek(substream, chunk, req);
 
                if (done == 0)
This page took 0.052655 seconds and 4 git commands to generate.