[alsa-devel] [PATCH] sound: using strlcpy instead of strncpy
Zhao Hongjiang
zhaohongjiang at huawei.com
Thu Jun 20 13:03:55 CEST 2013
for NUL terminated string, need alway set '\0' in the end.
Signed-off-by: Zhao Hongjiang <zhaohongjiang at huawei.com>
---
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
More information about the Alsa-devel
mailing list