Re: [PATCH] PPC: in celleb_show_cpuinfo() convert strncpy(x, y,sizeof(x)) to strlcpy

From: Ishizaki Kou
Date: Fri Mar 07 2008 - 03:15:36 EST


Roel Kluin <12o3l@xxxxxxxxxx> wrote:
> Roel Kluin wrote:
> > This patch was not yet tested. Please confirm it's right.
>
> was too quick with the send button. the batch below is probably better
> ---
> strncpy does not append '\0' if the length of the source string equals
> the size parameter, strlcpy does.
>
> Signed-off-by: Roel Kluin <12o3l@xxxxxxxxxx>

Acked-by: Kou Ishizaki <kou.ishizaki@xxxxxxxxxxxxx>

I tested Roel's 2nd patch and it works good on Celleb.

> ---
> diff --git a/arch/powerpc/platforms/celleb/setup.c b/arch/powerpc/platforms/celleb/setup.c
> index f27ae1e..cbe09d9 100644
> --- a/arch/powerpc/platforms/celleb/setup.c
> +++ b/arch/powerpc/platforms/celleb/setup.c
> @@ -81,8 +81,7 @@ static void celleb_show_cpuinfo(struct seq_file *m)
>
> static int __init celleb_machine_type_hack(char *ptr)
> {
> - strncpy(celleb_machine_type, ptr, sizeof(celleb_machine_type));
> - celleb_machine_type[sizeof(celleb_machine_type)-1] = 0;
> + strlcpy(celleb_machine_type, ptr, sizeof(celleb_machine_type));
> return 0;
> }
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@xxxxxxxxxx
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/