lkml.org 
[lkml]   [2019]   [Dec]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2 09/11] gpiolib: provide a dedicated function for setting lineinfo
On Thu, Dec 5, 2019 at 11:28 AM Bartosz Golaszewski
<bgolaszewski@baylibre.com> wrote:
> śr., 4 gru 2019 o 23:30 Andy Shevchenko <andy.shevchenko@gmail.com> napisał(a):
> > On Wed, Dec 4, 2019 at 6:02 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:

> > > + if (desc->name) {
> > > + strncpy(info->name, desc->name, sizeof(info->name));
> > > + info->name[sizeof(info->name) - 1] = '\0';
> > > + } else {
> > > + info->name[0] = '\0';
> > > + }
> > > +
> > > + if (desc->label) {
> > > + strncpy(info->consumer, desc->label, sizeof(info->consumer));
> > > + info->consumer[sizeof(info->consumer) - 1] = '\0';
> > > + } else {
> > > + info->consumer[0] = '\0';
> > > + }
> >
> > I think we have to fix GCC warnings first and then do whatever this patch does.
> >
>
> What GCC warnings are you referring to exactly?

stncpy() against partial string without NUL-terminator.

So, if desc->label is longer than info->consumer, it will be copied
partially. I don't check if the modern GCC clever enough to see the
next operation which does the termination.

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2019-12-05 11:22    [W:0.058 / U:33.376 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site