[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <55A7B251-8E1B-4935-B33F-B12DF1A2B382@linux.dev>
Date: Thu, 14 Aug 2025 17:17:52 +0200
From: Thorsten Blum <thorsten.blum@...ux.dev>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Jason Wessel <jason.wessel@...driver.com>,
Daniel Thompson <danielt@...nel.org>,
Douglas Anderson <dianders@...omium.org>,
Nir Lichtman <nir@...htman.org>,
Yuran Pereira <yuran.pereira@...mail.com>,
linux-hardening@...r.kernel.org,
Daniel Thompson <daniel@...cstar.com>,
kgdb-bugreport@...ts.sourceforge.net,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] kdb: Replace deprecated strcpy() with strscpy()
Hi Greg,
On 14. Aug 2025, at 16:35, Greg Kroah-Hartman wrote:
> On Thu, Aug 14, 2025 at 02:35:56PM +0200, Greg Kroah-Hartman wrote:
>> On Thu, Aug 14, 2025 at 02:03:37PM +0200, Thorsten Blum wrote:
>>> [...]
>>> - strcpy(kdb_grep_string, cp);
>>> + strscpy(kdb_grep_string, cp);
>>
>> If this was just a search/replace, it would have been done already, so
>> why is this ok?
>
> I missed that strscpy() can now handle 2 arguments like this, so yes,
> this should be ok.
>
> BUT, you just checked the length above this line, which now isn't
> needed, right? So this function can get simpler?
Yes, this could just be
memcpy(kdb_grep_string, cp, len + 1);
because we already know the length which strscpy() would just recompute
before calling memcpy() internally. I'll submit a v2.
>>> - strscpy(cmd_cur, cmd_hist[cmdptr], CMD_BUFLEN);
>>> + strscpy(cmd_cur, cmd_hist[cmdptr]);
>>
>> Same here. And other places...
>
> Sorry, this should also be ok, BUT it's really just doing the same exact
> thing, right?
Yes, it's the same because sizeof(cmd_cur) equals CMD_BUFLEN.
Thanks,
Thorsten
Powered by blists - more mailing lists