From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753946Ab1LUVbI (ORCPT ); Wed, 21 Dec 2011 16:31:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:18698 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750915Ab1LUVbF (ORCPT ); Wed, 21 Dec 2011 16:31:05 -0500 Date: Wed, 21 Dec 2011 16:30:55 -0500 From: Jason Baron To: greg@kroah.com, Bart Van Assche Cc: jim.cromie@gmail.com, joe@perches.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH 05/16] dynamic_debug: replace strcpy with strlcpy, in ddebug_setup_query() Message-ID: <20111221213055.GA30393@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.20 (2009-12-10) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 20, 2011 at 08:08:41AM +0000, Bart Van Assche wrote: > On Mon, Dec 19, 2011 at 10:12 PM, Jason Baron wrote: > > > > From: Jim Cromie > > > > Replace strcpy with strlcpy, and add define for the size constant. > > > > [jbaron@redhat.com: Use DDEBUG_STRING_SIZE for overflow check] > > Signed-off-by: Jim Cromie > > Signed-off-by: Jason Baron > > --- > >  lib/dynamic_debug.c |    8 +++++--- > >  1 files changed, 5 insertions(+), 3 deletions(-) > > > > diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c > > index 8c88b89..6fc8622 100644 > > --- a/lib/dynamic_debug.c > > +++ b/lib/dynamic_debug.c > > @@ -525,14 +525,16 @@ EXPORT_SYMBOL(__dynamic_netdev_dbg); > > > >  #endif > > > > -static __initdata char ddebug_setup_string[1024]; > > +#define DDEBUG_STRING_SIZE 1024 > > +static __initdata char ddebug_setup_string[DDEBUG_STRING_SIZE]; > > + > >  static __init int ddebug_setup_query(char *str) > >  { > > -       if (strlen(str) >= 1024) { > > +       if (strlen(str) >= DDEBUG_STRING_SIZE) { > >                pr_warn("ddebug boot param string too large\n"); > >                return 0; > >        } > > -       strcpy(ddebug_setup_string, str); > > +       strlcpy(ddebug_setup_string, str, DDEBUG_STRING_SIZE); > >        return 1; > >  } > > Sorry, but it's not clear to me why it make sense to introduce the > DDEBUG_STRING_SIZE macro instead of using ARRAY_SIZE(). > > Bart. Greg, The change suggested here by Bart isn't a functional change. If you think it warrants a re-post, let me know, but I am fine with it as-is. Thanks, -Jason