Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752869AbaGaWTE (ORCPT ); Thu, 31 Jul 2014 18:19:04 -0400 Received: from mail-yk0-f176.google.com ([209.85.160.176]:53576 "EHLO mail-yk0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751081AbaGaWTC (ORCPT ); Thu, 31 Jul 2014 18:19:02 -0400 MIME-Version: 1.0 In-Reply-To: <1406473878-12715-1-git-send-email-rickard_strandqvist@spectrumdigital.se> References: <1406473878-12715-1-git-send-email-rickard_strandqvist@spectrumdigital.se> Date: Thu, 31 Jul 2014 15:19:01 -0700 Message-ID: Subject: Re: [PATCH] scsi: 3w-9xxx.c: Cleaning up missing null-terminate in conjunction with strncpy From: adam radford To: Rickard Strandqvist Cc: Adam Radford , "James E.J. Bottomley" , linux-scsi , linux-kernel Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Jul 27, 2014 at 8:11 AM, Rickard Strandqvist wrote: > Replacing strncpy with strlcpy to avoid strings that lacks null terminate. > And use the sizeof on the to string rather than strlen on the from string. > > Signed-off-by: Rickard Strandqvist > --- > drivers/scsi/3w-9xxx.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c > index 0a73253..f4d2331 100644 > --- a/drivers/scsi/3w-9xxx.c > +++ b/drivers/scsi/3w-9xxx.c > @@ -621,7 +621,8 @@ static int twa_check_srl(TW_Device_Extension *tw_dev, int *flashed) > } > > /* Load rest of compatibility struct */ > - strncpy(tw_dev->tw_compat_info.driver_version, TW_DRIVER_VERSION, strlen(TW_DRIVER_VERSION)); > + strlcpy(tw_dev->tw_compat_info.driver_version, TW_DRIVER_VERSION, > + sizeof(tw_dev->tw_compat_info.driver_version)); > tw_dev->tw_compat_info.driver_srl_high = TW_CURRENT_DRIVER_SRL; > tw_dev->tw_compat_info.driver_branch_high = TW_CURRENT_DRIVER_BRANCH; > tw_dev->tw_compat_info.driver_build_high = TW_CURRENT_DRIVER_BUILD; > -- > 1.7.10.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ Rickard, This patch looks fine. Acked-by: Adam Radford -Adam -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/