Skip to content

Commit

Permalink
hwmon: (ntc_thermistor) Ensure that data->name string is terminated
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Guenter Roeck committed Jul 22, 2012
1 parent e2730be commit 0ef63e4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/hwmon/ntc_thermistor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 0ef63e4

Please sign in to comment.