Re: [PATCH] HID: uhid: refactor deprecated strncpy

2023-09-15 Thread Kees Cook
On Fri, Sep 15, 2023 at 09:36:23AM +0200, David Rheinsberg wrote: > Hi > > On Fri, Sep 15, 2023, at 7:13 AM, Kees Cook wrote: > >> - /* @hid is zero-initialized, strncpy() is correct, strlcpy() not */ > >> - len = min(sizeof(hid->name), sizeof(ev->u.create2.name)) - 1; > >> - strncpy(hid->name,

Re: [PATCH] HID: uhid: refactor deprecated strncpy

2023-09-15 Thread David Rheinsberg
Hi On Fri, Sep 15, 2023, at 7:13 AM, Kees Cook wrote: >> -/* @hid is zero-initialized, strncpy() is correct, strlcpy() not */ >> -len = min(sizeof(hid->name), sizeof(ev->u.create2.name)) - 1; >> -strncpy(hid->name, ev->u.create2.name, len); >> -len = min(sizeof(hid->phys), sizeof(e

Re: [PATCH] HID: uhid: refactor deprecated strncpy

2023-09-14 Thread Kees Cook
On Thu, Sep 14, 2023 at 10:47:21PM +, Justin Stitt wrote: > `strncpy` is deprecated for use on NUL-terminated destination strings [1]. > > We should prefer more robust and less ambiguous string interfaces. > > A suitable replacement is `strscpy` [2] due to the fact that it > guarantees NUL-te

[PATCH] HID: uhid: refactor deprecated strncpy

2023-09-14 Thread Justin Stitt
`strncpy` is deprecated for use on NUL-terminated destination strings [1]. We should prefer more robust and less ambiguous string interfaces. A suitable replacement is `strscpy` [2] due to the fact that it guarantees NUL-termination on the destination buffer without unnecessarily NUL-padding. Lo