ALSA: seq: Clear padded bytes at expanding events

There can be a small memory hole that may not be cleared at expanding
an event with the variable length type.  Make sure to clear it.

Reviewed-by: Jaroslav Kysela <perex@perex.cz>
Link: https://lore.kernel.org/r/20230523075358.9672-18-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
Takashi Iwai 2023-05-23 09:53:38 +02:00
parent f4487c42aa
commit f80e6d60d6

View File

@ -152,12 +152,16 @@ int snd_seq_expand_var_event(const struct snd_seq_event *event, int count, char
return -EINVAL;
if (copy_from_user(buf, (void __force __user *)event->data.ext.ptr, len))
return -EFAULT;
return newlen;
} else {
err = snd_seq_dump_var_event(event,
in_kernel ? seq_copy_in_kernel : seq_copy_in_user,
&buf);
if (err < 0)
return err;
}
err = snd_seq_dump_var_event(event,
in_kernel ? seq_copy_in_kernel : seq_copy_in_user,
&buf);
return err < 0 ? err : newlen;
if (len != newlen)
memset(buf + len, 0, newlen - len);
return newlen;
}
EXPORT_SYMBOL(snd_seq_expand_var_event);