meson: remote: fix coverity warning
authorYingyuan Zhu <yingyuan.zhu@amlogic.com>
Wed, 29 Aug 2018 08:17:30 +0000 (16:17 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Wed, 5 Sep 2018 15:38:27 +0000 (08:38 -0700)
PD#172716: meson: remote: fix coverity warning

The "strncpy" function does not ensure that the
string "ptable->tab.custom_name"ends with a null character.
So,the function "strncpy" is replaced by the function "snprintf".
This causes "Buffer not null terminated".

Change-Id: I4dd7ce89778ba8be7d60f3463e445f5a3a753061
Signed-off-by: Yingyuan Zhu <yingyuan.zhu@amlogic.com>
drivers/amlogic/input/remote/remote_meson.c

index b321e3f..43a360d 100644 (file)
@@ -417,7 +417,7 @@ static int get_custom_tables(struct device_node *node,
                        dev_err(chip->dev, "please config mapname item\n");
                        goto err;
                }
-               strncpy(ptable->tab.custom_name, uname, CUSTOM_NAME_LEN);
+               snprintf(ptable->tab.custom_name, CUSTOM_NAME_LEN, "%s", uname);
 
                dev_info(chip->dev, "ptable->custom_name = %s\n",
                                                ptable->tab.custom_name);