ASoC: fsl: use strncpy() to prevent copying of over-long names
authorDaniel Mack <daniel@zonque.org>
Sun, 19 Oct 2014 07:07:36 +0000 (09:07 +0200)
committerMark Brown <broonie@kernel.org>
Wed, 22 Oct 2014 10:38:01 +0000 (11:38 +0100)
Use strncpy() instead of strcpy(). That's not a security issue, as the
source buffer is taken from DT nodes, but we should still enforce bound
checks. Spotted by Coverity.

Signed-off-by: Daniel Mack <daniel@zonque.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/fsl/fsl_asrc.c
sound/soc/fsl/fsl_esai.c

index 3b14531..ed866e9 100644 (file)
@@ -792,7 +792,7 @@ static int fsl_asrc_probe(struct platform_device *pdev)
                return -ENOMEM;
 
        asrc_priv->pdev = pdev;
-       strcpy(asrc_priv->name, np->name);
+       strncpy(asrc_priv->name, np->name, sizeof(asrc_priv->name) - 1);
 
        /* Get the addresses and IRQ */
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
index 8bcdfda..a645e29 100644 (file)
@@ -734,7 +734,7 @@ static int fsl_esai_probe(struct platform_device *pdev)
                return -ENOMEM;
 
        esai_priv->pdev = pdev;
-       strcpy(esai_priv->name, np->name);
+       strncpy(esai_priv->name, np->name, sizeof(esai_priv->name) - 1);
 
        /* Get the addresses and IRQ */
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);