sound: using strlcpy instead of strncpy
PATCH 1/1 sound: using strlcpy instead of strncpy
for NUL terminated string, need alway set '\0' in the end.
Signed-off-by Zhao Hongjiang <[email protected]>
--- sound/oss/soundcard.c | 2 +- sound/soc/codecs/88pm860x-codec.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
sound/oss/soundcard.c +1 -1
@@ -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;
sound/soc/codecs/88pm860x-codec.c +1 -1
@@ -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,
Signature · 1 line
1.7.1
At Thu, 20 Jun 2013 19:03:55 +0800,
Quoted 14 lines · Zhao Hongjiang
for NUL terminated string, need alway set '\0' in the end.
Signed-off-by Zhao Hongjiang <[email protected]>--- sound/oss/soundcard.c | 2 +- sound/soc/codecs/88pm860x-codec.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)sound/oss/soundcard.c +0
-0
sound/oss/soundcard.c int *load_mixer_volumes(char *name, int *levels, int present) · line 102
Quoted 5 lines
sound/oss/soundcard.c +1
-1@@ -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));
This chunk is a wrong fix. The field doesn't have to be NUL-terminated if it's the max length.
thanks,
Takashi
Quoted 19 lines
sound/oss/soundcard.c +0
-0if (present) mixer_vols[n].num = n;sound/soc/codecs/88pm860x-codec.c +1
-1@@ -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,Signature · 1 line
1.7.1