diff options
author | Mengdong Lin <mengdong.lin@linux.intel.com> | 2016-07-20 09:53:12 +0800 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2016-07-20 07:46:45 +0200 |
commit | 9797e9893093dbbde9745faad5163c93be3ca3a6 (patch) | |
tree | 80557a82fa836bc853b64c30b67cd512fc6a1ee4 | |
parent | 1a0d49be70d716de4f40f50d6393aead56b748de (diff) | |
download | alsa-lib-9797e9893093dbbde9745faad5163c93be3ca3a6.tar.gz |
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>
-rw-r--r-- | src/topology/tplg_local.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/topology/tplg_local.h b/src/topology/tplg_local.h index 4d79aa7b..cfde4cc5 100644 --- a/src/topology/tplg_local.h +++ b/src/topology/tplg_local.h @@ -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; } |