hwmon: (ntc_thermistor) Ensure that data->name string is terminated
Guenter Roeck
maintainerPATCH 1/4 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.
Signed-off-by Guenter Roeck <[email protected]>
--- 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 ); +strncpy (data->name, pdev->id_entry->name,sizeof (data->name) -1 );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 14 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.Signed-off-by Guenter Roeck <[email protected]>--- drivers/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 ); +strncpy (data->name, pdev->id_entry->name,sizeof (data->name) -1 );switch (pdev->id_entry->driver_data) {case TYPE_NCPXXWB473 :
Please use strlcpy instead, it's meant exactly for this. strncpy is evil and should be discarded IMHO.
Signature · 6 lines
Jean Delvare _______________________________________________ lm-sensors mailing list [email protected] http://lists.lm-sensors.org/mailman/listinfo/lm-sensors