Re: [PATCH v1 1/1] usb: hcd: Bump local buffer size in rh_string()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 17, 2025 at 07:11:46AM +0100, Greg Kroah-Hartman wrote:
> On Thu, Jan 16, 2025 at 06:05:43PM +0200, Andy Shevchenko wrote:
> > GCC is not happy about the buffer size:
> > 
> > drivers/usb/core/hcd.c:441:48: error: ‘%s’ directive output may be truncated writing up to 64 bytes into a region of size between 35 and 99 [-Werror=format-truncation=]
> >   441 |                 snprintf (buf, sizeof buf, "%s %s %s", init_utsname()->sysname,
> >       |                                                ^~
> >   442 |                         init_utsname()->release, hcd->driver->description);
> >       |                         ~~~~~~~~~~~~~~~~~~~~~~~
> > 
> > Bump the size to get it enough for the possible strings.

...

> >  static unsigned
> >  rh_string(int id, struct usb_hcd const *hcd, u8 *data, unsigned len)
> >  {
> > -	char buf[100];
> > +	char buf[160];
> >  	char const *s;
> >  	static char const langids[4] = {4, USB_DT_STRING, 0x09, 0x04};
> 
> Worst case it's properly truncated so why do we need to worry about this
> "warning"?

With CONFIG_WERROR=y it's a compilation error. My goal is to have
i386_defconfig and x86_64_defconfig to be compiled with `make W=1`.

> And what compiler version is giving that, I don't see that
> here in my build testing.

`make W=1` (and be sure that CONFIG_WERROR=y).

$ gcc --version
gcc (Debian 14.2.0-12) 14.2.0

(IIRC that had been started with any GCC from v13?)

-- 
With Best Regards,
Andy Shevchenko






[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux