From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chen Gang Subject: Re: [PATCH] arch: parisc: kernel: using strlcpy() instead of strcpy() Date: Mon, 03 Jun 2013 16:50:03 +0800 Message-ID: <51AC58BB.20305@asianux.com> References: <51A6A8F3.2030200@asianux.com> <20130530150636.GA2121@udknight> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20130530150636.GA2121@udknight> Sender: linux-parisc-owner@vger.kernel.org To: Wang YanQing , "James E.J. Bottomley" , Helge Deller , Greg KH , Parisc List , "linux-kernel@vger.kernel.org" , Linux-Arch List-Id: linux-arch.vger.kernel.org On 05/30/2013 11:06 PM, Wang YanQing wrote: > What about add > boot_command_line[COMMAND_LINE_SIZE - 1] = '\0'; > to protect the following another strcpy? > > " > strcpy(command_line, boot_command_line); > " If the 'dest' length is not less than COMMAND_LINE_SIZE, the strlcpy() will copy 'COMMAND_LINE_SIZE - 1' contents, and always set '\0' in the end. So the next strcpy() will be safe. Thanks. -- Chen Gang Asianux Corporation From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from intranet.asianux.com ([58.214.24.6]:63520 "EHLO intranet.asianux.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751857Ab3FCIuz (ORCPT ); Mon, 3 Jun 2013 04:50:55 -0400 Message-ID: <51AC58BB.20305@asianux.com> Date: Mon, 03 Jun 2013 16:50:03 +0800 From: Chen Gang MIME-Version: 1.0 Subject: Re: [PATCH] arch: parisc: kernel: using strlcpy() instead of strcpy() References: <51A6A8F3.2030200@asianux.com> <20130530150636.GA2121@udknight> In-Reply-To: <20130530150636.GA2121@udknight> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: linux-arch-owner@vger.kernel.org List-ID: To: Wang YanQing , "James E.J. Bottomley" , Helge Deller , Greg KH , Parisc List , "linux-kernel@vger.kernel.org" , Linux-Arch Message-ID: <20130603085003.D7AWb_cwBGWSA7-u_t6tS8a7meLsA8VlUSN5osVjx28@z> On 05/30/2013 11:06 PM, Wang YanQing wrote: > What about add > boot_command_line[COMMAND_LINE_SIZE - 1] = '\0'; > to protect the following another strcpy? > > " > strcpy(command_line, boot_command_line); > " If the 'dest' length is not less than COMMAND_LINE_SIZE, the strlcpy() will copy 'COMMAND_LINE_SIZE - 1' contents, and always set '\0' in the end. So the next strcpy() will be safe. Thanks. -- Chen Gang Asianux Corporation