[PATCH v2] hwmon: (ntc_thermistor) Ensure that data->name string is terminated

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxx>
---
v2: Use strlcpy instead of strncpy

 drivers/hwmon/ntc_thermistor.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c
index 6da9696..74a6c58 100644
--- a/drivers/hwmon/ntc_thermistor.c
+++ b/drivers/hwmon/ntc_thermistor.c
@@ -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:
-- 
1.7.9.7


_______________________________________________
lm-sensors mailing list
lm-sensors@xxxxxxxxxxxxxx
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors


[Index of Archives]     [Linux Kernel]     [Linux Hardware Monitoring]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux