hwmon: (ntc_thermistor) Ensure that data->name string is terminated
authorGuenter Roeck <linux@roeck-us.net>
Tue, 19 Jun 2012 05:30:51 +0000 (22:30 -0700)
committerGuenter Roeck <linux@roeck-us.net>
Sun, 22 Jul 2012 04:48:44 +0000 (21:48 -0700)
Fix Coverity warning: Calling strncpy with a maximum size argument of 20 bytes
on destination array "data->name" of size 20 bytes might leave the destination
string unterminated.

Fix by replacing strncpy() with strlcpy() and by using sizeof() to determine
the maximum string length.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Jean Delvare <khali@linux-fr.org>
drivers/hwmon/ntc_thermistor.c

index 6da9696e182730ac9b7980ad356b2cc19cc01975..74a6c58d02187cd4dae86fa7c300a737c047c7a8 100644 (file)
@@ -351,7 +351,7 @@ static int __devinit ntc_thermistor_probe(struct platform_device *pdev)
 
        data->dev = &pdev->dev;
        data->pdata = pdata;
-       strncpy(data->name, pdev->id_entry->name, PLATFORM_NAME_SIZE);
+       strlcpy(data->name, pdev->id_entry->name, sizeof(data->name));
 
        switch (pdev->id_entry->driver_data) {
        case TYPE_NCPXXWB473: