Re: [PATCH v3] hwmon: refactor deprecated strncpy

2023-09-27 Thread Justin Stitt
On Wed, Sep 27, 2023 at 11:05 PM Justin Stitt wrote: > > On Wed, Sep 27, 2023 at 9:49 PM Guenter Roeck wrote: > > > > On Thu, Sep 21, 2023 at 05:41:46AM +, Justin Stitt wrote: > > > `strncpy` is deprecated for use on NUL-terminated destination strings [1]. > > > > > > Let's refactor this kcal

Re: [PATCH v3] hwmon: refactor deprecated strncpy

2023-09-27 Thread Justin Stitt
On Wed, Sep 27, 2023 at 9:49 PM Guenter Roeck wrote: > > On Thu, Sep 21, 2023 at 05:41:46AM +, Justin Stitt wrote: > > `strncpy` is deprecated for use on NUL-terminated destination strings [1]. > > > > Let's refactor this kcalloc() + strncpy() into a kmemdup_nul() which has > > more obvious be

Re: [PATCH v3] hwmon: refactor deprecated strncpy

2023-09-27 Thread Guenter Roeck
On Thu, Sep 21, 2023 at 05:41:46AM +, Justin Stitt wrote: > `strncpy` is deprecated for use on NUL-terminated destination strings [1]. > > Let's refactor this kcalloc() + strncpy() into a kmemdup_nul() which has > more obvious behavior and is less error prone. > > To avoid truncating the last

Re: [PATCH v3] hwmon: refactor deprecated strncpy

2023-09-23 Thread Kees Cook
On Thu, Sep 21, 2023 at 05:41:46AM +, Justin Stitt wrote: > `strncpy` is deprecated for use on NUL-terminated destination strings [1]. > > Let's refactor this kcalloc() + strncpy() into a kmemdup_nul() which has > more obvious behavior and is less error prone. > > To avoid truncating the last

[PATCH v3] hwmon: refactor deprecated strncpy

2023-09-21 Thread Justin Stitt
`strncpy` is deprecated for use on NUL-terminated destination strings [1]. Let's refactor this kcalloc() + strncpy() into a kmemdup_nul() which has more obvious behavior and is less error prone. To avoid truncating the last byte supply `...length + 1` to kmemdup_nul() as `element->string.length`