Re: [PATCH] bfs: prevent underflow in bfs_find_entry()
From: Tigran Aivazian
Date: Tue Mar 10 2020 - 14:22:57 EST
Hello,
On Tue, 10 Mar 2020 at 17:57, Walter Harms <wharms@xxxxxx> wrote:
> that raises the question why is there a len paramter in the first place.
> Surely the writer can make sure that there is always a NUL terminated
> string, then it would be possible the use a simple strcmp() and the
> range check is useless and can be removed.
>
> seems a question for the maintainer.
Please have a look at, for example,
fs/ufs/dir.c:ufs_find_entry()/ufs_match() functions --- they do almost
the same thing as the ones in bfs. And, presumably, the line "int
namelen = qstr->len;" in ufs_find_entry() is causing the static
checker warning too, just like the one in bfs which Dan mentioned and
fixed. So, let's not over-complicate things (or make a mountain out of
a molehill) and accept Dan's patch as is.
Kind regards,
Tigran