[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AANLkTinoCgO56O1kPNW3vjd9Nd1kY2SU34UH2RQa9qkE@mail.gmail.com>
Date: Tue, 5 Oct 2010 08:55:01 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Evgeny Kuznetsov <EXT-Eugeny.Kuznetsov@...ia.com>,
"H. Peter Anvin" <hpa@...or.com>
Cc: akpm@...ux-foundation.org, phillip@...gher.demon.co.uk,
hsweeten@...ionengravers.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/1] initramfs: strcpy destination string overflow
On Tue, Oct 5, 2010 at 1:44 AM, Evgeny Kuznetsov
<EXT-Eugeny.Kuznetsov@...ia.com> wrote:
> From: Evgeny Kuznetsov <ext-eugeny.kuznetsov@...ia.com>
>
> Function "strcpy()" is used without check for maximum allowed
> source string length and could cause destination string overflow.
> "strcpy()" is replaced by "strlcpy()" to prevent destination
> string overflow.
I think this is wrong.
If the name is too long to fit in the hash table, we should not create
a new hash entry at all, because we'd be returning the wrong
(truncated) name when we find it next time.
So it would be much better to just do
if (strlen(name) >= sizeof(q->name))
return NULL;
in find_link(), because as far as I can tell, the hard-linking is
always just an optimization.
Comments? Peter?
Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists