ALSA: seq: potential out of bounds in do_control()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 11 Feb 2015 15:10:54 +0000 (18:10 +0300)
committerTakashi Iwai <tiwai@suse.de>
Thu, 12 Feb 2015 10:07:48 +0000 (11:07 +0100)
Smatch complains that "control" is user specifigy and needs to be
capped.  The call tree to understand this warning is quite long.

snd_seq_write()  <-- get the event from the user
  snd_seq_client_enqueue_event()
    snd_seq_deliver_event()
      deliver_to_subscribers()
        snd_seq_deliver_single_event()
          snd_opl3_oss_event_input()
            snd_midi_process_event()
              do_control()

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/seq/seq_midi_emul.c

index 9b6470cdcf246f6e89ecf428d84dee0a25ad361e..7ba937399ac783c5cbf3c92f7497227d2feaa3cc 100644 (file)
@@ -269,6 +269,9 @@ do_control(struct snd_midi_op *ops, void *drv, struct snd_midi_channel_set *chse
 {
        int  i;
 
+       if (control >= ARRAY_SIZE(chan->control))
+               return;
+
        /* Switches */
        if ((control >=64 && control <=69) || (control >= 80 && control <= 83)) {
                /* These are all switches; either off or on so set to 0 or 127 */