From mboxrd@z Thu Jan 1 00:00:00 1970 From: Zhao Hongjiang Subject: [PATCH] sound: using strlcpy instead of strncpy Date: Thu, 20 Jun 2013 19:03:55 +0800 Message-ID: <51C2E19B.1080600@huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [119.145.14.65]) by alsa0.perex.cz (Postfix) with ESMTP id 345702608C7 for ; Thu, 20 Jun 2013 13:04:42 +0200 (CEST) List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: perex@perex.cz Cc: tiwai@suse.de, alsa-devel@alsa-project.org, broonie@kernel.org, lgirdwood@gmail.com, wfp5p@virginia.edu List-Id: alsa-devel@alsa-project.org for NUL terminated string, need alway set '\0' in the end. Signed-off-by: Zhao Hongjiang --- sound/oss/soundcard.c | 2 +- sound/soc/codecs/88pm860x-codec.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/oss/soundcard.c b/sound/oss/soundcard.c index e778034..53ac987 100644 --- a/sound/oss/soundcard.c +++ b/sound/oss/soundcard.c @@ -99,7 +99,7 @@ int *load_mixer_volumes(char *name, int *levels, int present) } n = num_mixer_volumes++; - strncpy(mixer_vols[n].name, name, 32); + strlcpy(mixer_vols[n].name, name, sizeof(mixer_vols[n].name)); if (present) mixer_vols[n].num = n; diff --git a/sound/soc/codecs/88pm860x-codec.c b/sound/soc/codecs/88pm860x-codec.c index 60159c0..6b2e6b3 100644 --- a/sound/soc/codecs/88pm860x-codec.c +++ b/sound/soc/codecs/88pm860x-codec.c @@ -1447,7 +1447,7 @@ static int pm860x_codec_probe(struct platform_device *pdev) goto out; } pm860x->irq[i] = res->start + chip->irq_base; - strncpy(pm860x->name[i], res->name, MAX_NAME_LEN); + strlcpy(pm860x->name[i], res->name, sizeof(pm860x->name[i])); } ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_pm860x, -- 1.7.1