提交 8954c44f 编写于 作者: X Xu Panda 提交者: Darrick J. Wong

xfs: use strscpy() to instead of strncpy()

The implementation of strscpy() is more robust and safer.
That's now the recommended way to copy NUL-terminated strings.
Signed-off-by: NXu Panda <xu.panda@zte.com.cn>
Signed-off-by: NYang Yang <yang.yang29@zte.com.cn>
Reviewed-by: NDarrick J. Wong <djwong@kernel.org>
Signed-off-by: NDarrick J. Wong <djwong@kernel.org>
上级 6d796c50
...@@ -212,9 +212,7 @@ __xfs_xattr_put_listent( ...@@ -212,9 +212,7 @@ __xfs_xattr_put_listent(
offset = context->buffer + context->count; offset = context->buffer + context->count;
memcpy(offset, prefix, prefix_len); memcpy(offset, prefix, prefix_len);
offset += prefix_len; offset += prefix_len;
strncpy(offset, (char *)name, namelen); /* real name */ strscpy(offset, (char *)name, namelen + 1); /* real name */
offset += namelen;
*offset = '\0';
compute_size: compute_size:
context->count += prefix_len + namelen + 1; context->count += prefix_len + namelen + 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册