[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250519032642.GB158804@mit.edu>
Date: Sun, 18 May 2025 23:26:42 -0400
From: "Theodore Ts'o" <tytso@....edu>
To: Ethan Carter Edwards <ethan@...ancedwards.com>
Cc: Andreas Dilger <adilger.kernel@...ger.ca>, linux-ext4@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH] ext4: replace strcpy() with strscpy() in
ext4_init_dot_dotdot()
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
Powered by blists - more mailing lists