Re: [PATCH] staging: rtl8192e: Replace strcpy with strscpy in rtl819x_translate_scan
From: Dan Carpenter
Date: Sat Aug 24 2024 - 07:18:36 EST
On Sat, Aug 24, 2024 at 08:35:03AM +0200, Christophe JAILLET wrote:
> Le 21/08/2024 à 20:23, Dan Carpenter a écrit :
> > On Tue, Aug 20, 2024 at 09:38:22PM +0200, Christophe JAILLET wrote:
> > > - if a "mode" matches, do we need to iterate the whole rtllib_modes
> > > array? (have a look at wireless_mode)
> > >
> >
> > Can only one mode be set at a time?
> >
> > regards,
> > dan carpenter
> >
> >
> >
>
> Hmm, apparently several can be set (see [1])
>
> Base on a few lines below, it looks that WIRELESS_MODE_N_24G is exclusive
> from the other ones.
>
> So the 6 char array seems to be sized either for "N-24G", either for a
> concatenation of a few other modes that won't exceed the size of the buffer.
>
Yeah. I started to review this patch and found the same thing but I never hit
send on my review. 6 chars is enough. If you look at the commit which changed
the buffer size to 6, anything larger would cause a GCC checker warning about
truncating strings.
Still, it's kind of ugly that we need to do this much research to verify that
the code isn't a memory corruption bug. It doesn't feel future proof either.
It would be nicer if this were obviously safe from just reviewing the function.
regards,
dan carpenter