From 847595338527cdb37d96f9a5c729ddecb7c7c36c Mon Sep 17 00:00:00 2001 From: Alexander Zarochentsev Date: Wed, 20 Jul 2022 19:05:53 +0300 Subject: [PATCH] LU-16060 osd-ldiskfs: copy nul byte terminator in writelink memcpy() call in osd_ldiskfs_writelink() doesn't copy the nul terminator byte from the source buffer, leaving the space after target link name uninialized which is ok for the kernel code and debugfs but not e2fsck. Lustre-change: https://review.whamcloud.com/48092 Lustre-commit: 907dc0a2d333f2df2d654a968fc50f8cc05b779d Signed-off-by: Alexander Zarochentsev HPE-bug-id: LUS-11103 Change-Id: I914f2c78e1a6571bf360a23b0ede8c70502bf0df Reviewed-by: Artem Blagodarenko Reviewed-by: Andrew Perepechko Reviewed-by: Andreas Dilger Reviewed-on: https://review.whamcloud.com/48301 Tested-by: jenkins Tested-by: Maloo --- lustre/osd-ldiskfs/osd_io.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index 8cc78c4..54bdc41 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -2003,7 +2003,8 @@ static int osd_ldiskfs_writelink(struct inode *inode, char *buffer, int buflen) /* LU-2634: clear the extent format for fast symlink */ ldiskfs_clear_inode_flag(inode, LDISKFS_INODE_EXTENTS); - memcpy((char *)&LDISKFS_I(inode)->i_data, (char *)buffer, buflen); + /* Copying the NUL byte terminating the link target as well */ + memcpy((char *)&LDISKFS_I(inode)->i_data, (char *)buffer, buflen + 1); spin_lock(&inode->i_lock); LDISKFS_I(inode)->i_disksize = buflen; i_size_write(inode, buflen); -- 1.8.3.1