Re: [PATCH 03/35] fbdev: sisfb: Use safer strscpy() instead of strcpy()
David Laight <[email protected]>
| Newsgroups | org.kernel.vger.linux-parisc,org.freedesktop.lists.dri-devel,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-fbdev,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <20260425120235.2ec10089@pumpkin> |
On Sat, 25 Apr 2026 10:08:08 +0200 Helge Deller <[email protected]> wrote: > Hello Ai, ... > > - strcpy(ivideo->myid, "SiS 730"); > > + strscpy(ivideo->myid, "SiS 730"); > > The compiler knows at build time the length of myid, and the "SIS 730" string. > Using strscpy() has no benefit here either. Contrary, the code generated > because of using strscpy() is probably even larger. > Don't replace such code with strscpy(). Both should get converted to a memcpy(). If you increase the literal to be too long I'm pretty sure you'll get a compiler warning/error from strcpy(). OTOH strscpy() is more likely to truncate the string (I'd need to check). So leaving it as strcpy() is fine - and possibly even better. The header files might get changed to error strcpy() unless the compiler knows the source string has a constant length and the destination is big enough - but that hasn't been done yet. David