drm/modes: use strscpy() to instead of strncpy()
Subsystems (2)
PATCH 1/1 drm/modes: use strscpy() to instead of strncpy()
From: Xu Panda <[email protected]>
The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL terminated strings.
Signed-off-by Xu Panda <[email protected]>
Signed-off-by Yang Yang <[email protected]>
--- drivers/gpu/drm/drm_modes.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_modes.c +2 -4
@@ -2081,8 +2081,7 @@ void drm_mode_convert_to_umode(struct drm_mode_modeinfo *out,break ; } -strncpy (out->name, in->name,DRM_DISPLAY_MODE_LEN ); - out->name[DRM_DISPLAY_MODE_LEN -1 ] =0 ; +strscpy (out->name, in->name,DRM_DISPLAY_MODE_LEN ); }/**
@@ -2123,8 +2122,7 @@ int drm_mode_convert_umode(struct drm_device *dev,* useful for the kernel->userspace direction anyway. */ out->type = in->type &DRM_MODE_TYPE_ALL ; -strncpy (out->name, in->name,DRM_DISPLAY_MODE_LEN ); - out->name[DRM_DISPLAY_MODE_LEN -1 ] =0 ; +strscpy (out->name, in->name,DRM_DISPLAY_MODE_LEN );/* Clearing picture aspect ratio bits from out flags, * as the aspect-ratio information is not stored in
Signature · 1 line
2.15.2