Skip to content

Commit

Permalink
iio: change strncpy+truncation to strlcpy
Browse files Browse the repository at this point in the history
Generated by scripts/coccinelle/misc/strncpy_truncation.cocci

Signed-off-by: Dominique Martinet <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
  • Loading branch information
martinetd authored and jic23 committed Jul 15, 2018
1 parent ef89f4b commit cd570e6
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions drivers/iio/common/st_sensors/st_sensors_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,7 @@ void st_sensors_of_name_probe(struct device *dev,
return;

/* The name from the OF match takes precedence if present */
strncpy(name, of_id->data, len);
name[len - 1] = '\0';
strlcpy(name, of_id->data, len);
}
EXPORT_SYMBOL(st_sensors_of_name_probe);
#else
Expand Down
3 changes: 1 addition & 2 deletions drivers/iio/pressure/st_pressure_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@ static int st_press_i2c_probe(struct i2c_client *client,
if ((ret < 0) || (ret >= ST_PRESS_MAX))
return -ENODEV;

strncpy(client->name, st_press_id_table[ret].name,
strlcpy(client->name, st_press_id_table[ret].name,
sizeof(client->name));
client->name[sizeof(client->name) - 1] = '\0';
} else if (!id)
return -ENODEV;

Expand Down

0 comments on commit cd570e6

Please sign in to comment.