lkml.org 
[lkml]   [2018]   [May]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH v2] powerpc/64: Fix build failure with GCC 8.1
Date
From: Christophe LEROY
> Sent: 29 May 2018 10:37
...
> >>>> - strncpy(new_part->header.name, name, 12);
> >>>> + memcpy(new_part->header.name, name, strnlen(name,
> >>>> sizeof(new_part->header.name)));
> >>>
> >>>
> >>> The comment for nvram_header.lgnth says:
> >>>
> >>> /* Terminating null required only for names < 12 chars. */
> >>>
> >>> This will not terminate the string with a zero (the struct is
> >>> allocated with kmalloc).
> >>> So the original code is correct, the new one isn't.
> >>
> >> Right, then I have to first zeroize the destination.
> >
> > Using kzalloc() instead of kmalloc() will do.
> >
> > Still, papering around these warnings seems to obscure things, IMHO.
> > And it increases code size, as you had to add a call to strnlen().
>
> Right but then, what is the best solution to elimate that warning ?

Time to add the I_really_mean_strncy() function.

David

\
 
 \ /
  Last update: 2018-05-29 17:31    [W:0.091 / U:3.736 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site