[Cbe-oss-dev] [PATCH] powerpc/cell: strncpy does not null terminate string

Ken Kawakami ken.kawakami at toshiba.co.jp
Tue Jul 21 19:31:16 EST 2009


Arnd-san, Roel-san,

Thanks for pointing us to the redundant cord portion.

> On Friday 17 July 2009, Roel Kluin wrote:
> > 
> >  static int __init celleb_machine_type_hack(char *ptr)
> >  {
> > -       strncpy(celleb_machine_type, ptr, sizeof(celleb_machine_type));
> > +       strlcpy(celleb_machine_type, ptr, sizeof(celleb_machine_type));
> >         celleb_machine_type[sizeof(celleb_machine_type)-1] = 0;
> >         return 0;
> 
> This still is pointless as long as you keep the explicit null-termination
> in the next line, the patch still doesn't change anything significant.
> 
> The file is maintained by Ishizaki Kou, if he would prefer to take a
> patch replacing the two lines with one, that's fine with me, otherwise
> I just wouldn't bother. You still only gain a few bytes of inittext, but
> that is discarded at boot time.

We prefer to take the patch which is replacing the two lines with one.
-       strncpy(celleb_machine_type, ptr, sizeof(celleb_machine_type));
+       strlcpy(celleb_machine_type, ptr, sizeof(celleb_machine_type));
-       celleb_machine_type[sizeof(celleb_machine_type)-1] = 0;

Thanks,
Ken Kawakami


More information about the cbe-oss-dev mailing list