Whamcloud - gitweb
LU-16060 osd-ldiskfs: copy nul byte terminator in writelink 92/48092/2
authorAlexander Zarochentsev <alexander.zarochentsev@hpe.com>
Wed, 20 Jul 2022 16:05:53 +0000 (19:05 +0300)
committerOleg Drokin <green@whamcloud.com>
Fri, 19 Aug 2022 04:32:11 +0000 (04:32 +0000)
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.

HPE-bug-id: LUS-11103

Signed-off-by: Alexander Zarochentsev <alexander.zarochentsev@hpe.com>
Change-Id: I914f2c78e1a6571bf360a23b0ede8c70502bf0df
Reviewed-on: https://review.whamcloud.com/48092
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Artem Blagodarenko <ablagodarenko@ddn.com>
Reviewed-by: Andrew Perepechko <andrew.perepechko@hpe.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/osd-ldiskfs/osd_io.c

index 068ef49..4896da6 100644 (file)
@@ -2062,7 +2062,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);