lkml.org 
[lkml]   [2019]   [Mar]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/4] leds: netdev trigger: use memcpy in device_name_store
Hello,

On Wed, Mar 13, 2019 at 09:26:12PM +0100, Rasmus Villemoes wrote:
> --- a/drivers/leds/trigger/ledtrig-netdev.c
> +++ b/drivers/leds/trigger/ledtrig-netdev.c
> @@ -122,7 +122,8 @@ static ssize_t device_name_store(struct device *dev,
> trigger_data->net_dev = NULL;
> }
>
> - strncpy(trigger_data->device_name, buf, size);
> + memcpy(trigger_data->device_name, buf, size);
> + trigger_data->device_name[size] = '\0';

This is open-coding

strlcpy(trigger_data->device_name, buf, size);

Best regards
Uwe

> if (size > 0 && trigger_data->device_name[size - 1] == '\n')
> trigger_data->device_name[size - 1] = 0;

--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |

\
 
 \ /
  Last update: 2019-03-14 10:30    [W:0.280 / U:1.856 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site