From mboxrd@z Thu Jan 1 00:00:00 1970 Received: with ECARTIS (v1.0.0; list linux-mips); Tue, 28 May 2013 14:34:48 +0200 (CEST) Received: from nbd.name ([46.4.11.11]:51569 "EHLO nbd.name" rhost-flags-OK-OK-OK-OK) by eddie.linux-mips.org with ESMTP id S6827530Ab3E1Mer0Pakj (ORCPT ); Tue, 28 May 2013 14:34:47 +0200 Message-ID: <51A4A33E.3000605@openwrt.org> Date: Tue, 28 May 2013 14:29:50 +0200 From: John Crispin User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 MIME-Version: 1.0 To: Chen Gang CC: linux-mips@linux-mips.org Subject: Re: [PATCH] arch: mips: lantiq: using strlcpy() instead of strncpy() References: <51A1BF15.7070905@asianux.com> In-Reply-To: <51A1BF15.7070905@asianux.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Return-Path: X-Envelope-To: <"|/home/ecartis/ecartis -s linux-mips"> (uid 0) X-Orcpt: rfc822;linux-mips@linux-mips.org Original-Recipient: rfc822;linux-mips@linux-mips.org X-archive-position: 36620 X-ecartis-version: Ecartis v1.0.0 Sender: linux-mips-bounce@linux-mips.org Errors-to: linux-mips-bounce@linux-mips.org X-original-sender: blogic@openwrt.org Precedence: bulk List-help: List-unsubscribe: List-software: Ecartis version 1.0.0 List-Id: linux-mips X-List-ID: linux-mips List-subscribe: List-owner: List-post: List-archive: X-list: linux-mips On 26/05/13 09:51, Chen Gang wrote: > 'compatible' is used by strlen() in __of_device_is_compatible(). > > So for NUL terminated string, need always be sure of ended by zero. > > 'of_ids' is not a structure in "include/uapi/*", so not need initialize > all bytes, just use strlcpy() instead of strncpy(). > > > Signed-off-by: Chen Gang Acked-by: John Crispin > --- > arch/mips/lantiq/prom.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/arch/mips/lantiq/prom.c b/arch/mips/lantiq/prom.c > index 9f9e875..49c4603 100644 > --- a/arch/mips/lantiq/prom.c > +++ b/arch/mips/lantiq/prom.c > @@ -112,7 +112,7 @@ int __init plat_of_setup(void) > if (!of_have_populated_dt()) > panic("device tree not present"); > > - strncpy(of_ids[0].compatible, soc_info.compatible, > + strlcpy(of_ids[0].compatible, soc_info.compatible, > sizeof(of_ids[0].compatible)); > strncpy(of_ids[1].compatible, "simple-bus", > sizeof(of_ids[1].compatible));