]> git.alsa-project.org Git - alsa-lib.git/commitdiff
seq: Add overflow check in snd_seq_ev_set_ump_data()
authorTakashi Iwai <tiwai@suse.de>
Thu, 24 Aug 2023 17:24:03 +0000 (19:24 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 24 Aug 2023 17:24:03 +0000 (19:24 +0200)
It's better to add a sanity check than sorry for breaking.
Now the function return -EINVAL.

Closes: https://github.com/alsa-project/alsa-lib/issues/346
Signed-off-by: Takashi Iwai <tiwai@suse.de>
include/seqmid.h

index 4089ac207861d007c62b28d16af8531bca7ee951..da34699994b0883a05149cb8f32a3460dc099b58 100644 (file)
@@ -300,10 +300,13 @@ static inline void snd_seq_ev_set_ump(snd_seq_ump_event_t *ev)
  * \param data UMP packet data
  * \param bytes UMP packet size in bytes
  */
-static inline void snd_seq_ev_set_ump_data(snd_seq_ump_event_t *ev, void *data, size_t bytes)
+static inline int snd_seq_ev_set_ump_data(snd_seq_ump_event_t *ev, void *data, size_t bytes)
 {
+       if (bytes > 16)
+               return -EINVAL;
        snd_seq_ev_set_ump(ev);
        memcpy(ev->ump, data, bytes);
+       return 0;
 }
 
 /* set and send a queue control event */