hwmon: (ntc_thermistor) Ensure that data->name string is terminated
Guenter Roeck
maintainerPATCH v2 1/1 hwmon: (ntc_thermistor) Ensure that data->name string is terminated
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.
---
v2: Use strlcpy instead of strncpy
drivers/hwmon/ntc_thermistor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/ntc_thermistor.c +1 -1
@@ -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 :
Signature · 7 lines
1.7.9.7 _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
Quoted 19 lines · Guenter Roeck
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()withstrlcpy()and by usingsizeof()to determine the maximum string length.Signed-off-by Guenter Roeck <[email protected]>---
v2: Use strlcpy instead of strncpydrivers/hwmon/ntc_thermistor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hwmon/ntc_thermistor.c +0
-0
drivers/hwmon/ntc_thermistor.c static int __devinit ntc_thermistor_probe(struct platform_device *pdev) · line 357
Quoted 8 lines
drivers/hwmon/ntc_thermistor.c +1
-1@@ -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 :
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors