Re: possible fix (linux-ntfs3)

From: syzbot
Date: Mon Sep 02 2024 - 08:23:06 EST


> #syz test:https://github.com/Paragon-Software-Group/linux-ntfs3.git master

unknown command "test:https://github.com/Paragon-Software-Group/linux-ntfs3.git";

>
> diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
> index 128d49512f5d..c08bbacc0030 100644
> --- a/fs/ntfs3/super.c
> +++ b/fs/ntfs3/super.c
> @@ -125,8 +125,9 @@ void ntfs_inode_printk(struct inode *inode, const
> char *fmt, ...)
>
>          if (de) {
>              spin_lock(&de->d_lock);
> -            snprintf(name, sizeof(s_name_buf), " \"%s\"",
> -                 de->d_name.name);
> +            if (snprintf(name, sizeof(s_name_buf), " \"%s\"",
> +                     de->d_name.name) >= sizeof(s_name_buf))
> +                name[sizeof(s_name_buf) - 1] = 0;
>              spin_unlock(&de->d_lock);
>          } else {
>              name[0] = 0;
>