Re: [PATCH] ext4: replace strcpy() with strscpy() in ext4_init_dot_dotdot()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, May 18, 2025 at 12:48:50PM -0400, Ethan Carter Edwards wrote:
> strcpy() is deprecated; use strscpy() instead.

We never actually needed to use strcpy here, actually, becase de->name
is not NUL-terminated.  Instead, we have de->name_len which tells us
how many characters are in a directory entry's name.

So we could just as easily replace:

	strcpy(de->name, ".")

with

	de->name[0] = '.'


and

	strcpy(de->name, ".")
with

	de->name[0] = de->name[1] = '.'

.... if you really want to get rid of the evil strcpy call.  As it
turns out, it's super easy to assure oneself of why what's currently
there is safe, but you really want it to go away for religious reasons
then you might as well do it in a more performant way.

Also note that there is a similar use of strcpy() in fs/ext4/inline.c.
If you really want to "fix" things in fs/ext4/inode.c, you might as
well fix it in all of sources files in fs/ext4.

Cheeres,

					- Ted




[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux