Skip to content

Commit

Permalink
dma-buf/sync_file: use strscpy to replace strlcpy
Browse files Browse the repository at this point in the history
The strlcpy should not be used because it doesn't limit the source
length. Preferred is strscpy.

Signed-off-by: XueBing Chen <[email protected]>
Signed-off-by: Daniel Vetter <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
  • Loading branch information
XueBing Chen authored and danvet committed Aug 10, 2022
1 parent 7350b2a commit bcfa6be
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/dma-buf/sync_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ EXPORT_SYMBOL(sync_file_get_fence);
char *sync_file_get_name(struct sync_file *sync_file, char *buf, int len)
{
if (sync_file->user_name[0]) {
strlcpy(buf, sync_file->user_name, len);
strscpy(buf, sync_file->user_name, len);
} else {
struct dma_fence *fence = sync_file->fence;

Expand Down Expand Up @@ -172,7 +172,7 @@ static struct sync_file *sync_file_merge(const char *name, struct sync_file *a,
return NULL;
}
sync_file->fence = fence;
strlcpy(sync_file->user_name, name, sizeof(sync_file->user_name));
strscpy(sync_file->user_name, name, sizeof(sync_file->user_name));
return sync_file;
}

Expand Down Expand Up @@ -262,9 +262,9 @@ static long sync_file_ioctl_merge(struct sync_file *sync_file,
static int sync_fill_fence_info(struct dma_fence *fence,
struct sync_fence_info *info)
{
strlcpy(info->obj_name, fence->ops->get_timeline_name(fence),
strscpy(info->obj_name, fence->ops->get_timeline_name(fence),
sizeof(info->obj_name));
strlcpy(info->driver_name, fence->ops->get_driver_name(fence),
strscpy(info->driver_name, fence->ops->get_driver_name(fence),
sizeof(info->driver_name));

info->status = dma_fence_get_status(fence);
Expand Down

0 comments on commit bcfa6be

Please sign in to comment.