diff options
author | Xu Panda <xu.panda@zte.com.cn> | 2023-02-01 09:31:34 -0800 |
---|---|---|
committer | Darrick J. Wong <djwong@kernel.org> | 2023-02-05 08:48:11 -0800 |
commit | 8954c44ff47749255a2ee2b1d08ec3deb8345bc1 (patch) | |
tree | 019f5265523626dd80aa272d2a5e27ef3fbea400 /fs/xfs | |
parent | 6d796c50f84ca79f1722bb131799e5a5710c4700 (diff) | |
download | linux-stable-8954c44ff47749255a2ee2b1d08ec3deb8345bc1.tar.gz linux-stable-8954c44ff47749255a2ee2b1d08ec3deb8345bc1.tar.bz2 linux-stable-8954c44ff47749255a2ee2b1d08ec3deb8345bc1.zip |
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: Xu Panda <xu.panda@zte.com.cn>
Signed-off-by: Yang Yang <yang.yang29@zte.com.cn>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Diffstat (limited to 'fs/xfs')
-rw-r--r-- | fs/xfs/xfs_xattr.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c index 10aa1fd39d2b..913c1794bc2f 100644 --- a/fs/xfs/xfs_xattr.c +++ b/fs/xfs/xfs_xattr.c @@ -212,9 +212,7 @@ __xfs_xattr_put_listent( offset = context->buffer + context->count; memcpy(offset, prefix, prefix_len); offset += prefix_len; - strncpy(offset, (char *)name, namelen); /* real name */ - offset += namelen; - *offset = '\0'; + strscpy(offset, (char *)name, namelen + 1); /* real name */ compute_size: context->count += prefix_len + namelen + 1; |