mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-02 09:01:48 -05:00
topology: Check address and length before string copy
elem_copy_text() is widely used for string copy in topology. Because some name fields are not mandatory for users, sometimes the source can be invalid and we should not do the copy. So we add check here. Signed-off-by: Mengdong Lin <mengdong.lin@linux.intel.com> Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
1a0d49be70
commit
9797e98930
1 changed files with 3 additions and 0 deletions
|
|
@ -253,6 +253,9 @@ struct tplg_elem* tplg_elem_new_common(snd_tplg_t *tplg,
|
|||
|
||||
static inline void elem_copy_text(char *dest, const char *src, int len)
|
||||
{
|
||||
if (!dest || !src || !len)
|
||||
return;
|
||||
|
||||
strncpy(dest, src, len);
|
||||
dest[len - 1] = 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue