[PATCH] drm/modes: refactor deprecated strncpy
Kees Cook
keescook at chromium.org
Fri Sep 15 04:30:43 UTC 2023
On Thu, Sep 14, 2023 at 06:08:44PM +0000, 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-termination on the destination buffer and doesn't incur the
> performance loss of unnecessarily NUL-padding.
How did you decide it didn't need %NUL padding?
I suspect it should have it, as I see what looks like full struct copies
happening in places:
struct drm_mode_modeinfo umode;
...
struct drm_property_blob *blob;
drm_mode_convert_to_umode(&umode, mode);
blob = drm_property_create_blob(crtc->dev,
sizeof(umode), &umode);
Can you send a v2 using strscpy_pad() instead?
Thanks!
-Kees
--
Kees Cook
More information about the dri-devel
mailing list