Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp642490ybe; Wed, 11 Sep 2019 02:24:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqxe1hfbU5ISxT3adZYH0Q4clsaPzdVOpzEMAGoul9P8jY3n8f+TDdHoPbPsDjCNmncEFQ+b X-Received: by 2002:a05:6402:a48:: with SMTP id bt8mr35220058edb.86.1568193874639; Wed, 11 Sep 2019 02:24:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568193874; cv=none; d=google.com; s=arc-20160816; b=i1fNBfIm0/ryMexg1BB7/Y366U7PDkgG9Wc/4Hapwg0WkXKOtMv1yL/bj6Y7C+w+M8 QHMbWBEtqjkJUceo6ccuFaiI2Myj6Bfrr4pyrNBy4Iswl1frW4L5aVBE1lOKxgcVAhRp K9DYFDc1wTKSZ+F7rzpBqKUVY1mq0rtiFoGgplWJmx7Em9fx6L8eD366pki0YtVGA6I2 Q20lOTYztgh9cmF8Bg1cL6HJ8Qt+6vcfAottd8JmSd9Pyi0/wyTjjHdBGpXsOPtyduq5 MvP1detIw954jKRHejibbC91lMXl4t6ozDgLPrus7j0ufXDrY21CoUx/8LSoT92/H/Pe Q9xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:in-reply-to:cc:references:message-id :date:subject:mime-version:from:content-transfer-encoding; bh=Qa2DgpVy4g5HttaK+XQq45UeIlkOZbQzzivBHkMg7UU=; b=rZIGDE6TNAUpq3BB8shiumqcm6GbuGosgPJbLsYihAIUVomd/qoCE0iNZvv9nyUjYQ hLat0+c7W7srlMJseZqwKyHwT780ZSVn74tsSQpIHcIZlCVbqfagd2XP2UsJ23faVbow qm5N3i+OFFyZv1d0W7r0yU1ZzDokS1eNsjrFUQjHdVKTITe72Qtbsi/fXolmrB4Tup+Y URTX8oGkhaib665wT6CBYSVyimYk2Q0q+nT987e6YWBn9+vB8yF0kPDoAs21tqAWCLy0 7sYV2ke7lK2Z4rh6oB+U6XbW3aDhu+GryUby8xXQVBR2nGAxwD9KYZRDw6n4rR71CPmh AK7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v31si12454743edm.402.2019.09.11.02.24.10; Wed, 11 Sep 2019 02:24:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727420AbfIKJV5 convert rfc822-to-8bit (ORCPT + 99 others); Wed, 11 Sep 2019 05:21:57 -0400 Received: from mxout017.mail.hostpoint.ch ([217.26.49.177]:11331 "EHLO mxout017.mail.hostpoint.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726579AbfIKJV5 (ORCPT ); Wed, 11 Sep 2019 05:21:57 -0400 Received: from [10.0.2.46] (helo=asmtp013.mail.hostpoint.ch) by mxout017.mail.hostpoint.ch with esmtp (Exim 4.92.2 (FreeBSD)) (envelope-from ) id 1i7yor-000O7j-Ec; Wed, 11 Sep 2019 11:21:45 +0200 Received: from [213.55.220.251] (helo=[100.66.103.90]) by asmtp013.mail.hostpoint.ch with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.2 (FreeBSD)) (envelope-from ) id 1i7yor-000El9-4u; Wed, 11 Sep 2019 11:21:45 +0200 X-Authenticated-Sender-Id: sandro@volery.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT From: Sandro Volery Mime-Version: 1.0 (1.0) Subject: Re: [PATCH] Staging: octeon: Avoid several usecases of strcpy Date: Wed, 11 Sep 2019 11:21:44 +0200 Message-Id: References: <20190911091659.GI15977@kadam> Cc: devel@driverdev.osuosl.org, gregkh@linuxfoundation.org, davem@davemloft.net, linux-kernel@vger.kernel.org, aaro.koskinen@iki.fi In-Reply-To: <20190911091659.GI15977@kadam> To: Dan Carpenter X-Mailer: iPhone Mail (17A5831c) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11 Sep 2019, at 11:17, Dan Carpenter wrote: > > On Wed, Sep 11, 2019 at 11:04:38AM +0200, Sandro Volery wrote: >> >> >>>> On 11 Sep 2019, at 10:52, Dan Carpenter wrote: >>> >>> On Wed, Sep 11, 2019 at 08:23:59AM +0200, Sandro Volery wrote: >>>> strcpy was used multiple times in strcpy to write into dev->name. >>>> I replaced them with strscpy. >>>> >>>> Signed-off-by: Sandro Volery >>>> --- >>>> drivers/staging/octeon/ethernet.c | 16 ++++++++-------- >>>> 1 file changed, 8 insertions(+), 8 deletions(-) >>>> >>>> diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c >>>> index 8889494adf1f..cf8e9a23ebf9 100644 >>>> --- a/drivers/staging/octeon/ethernet.c >>>> +++ b/drivers/staging/octeon/ethernet.c >>>> @@ -784,7 +784,7 @@ static int cvm_oct_probe(struct platform_device *pdev) >>>> priv->imode = CVMX_HELPER_INTERFACE_MODE_DISABLED; >>>> priv->port = CVMX_PIP_NUM_INPUT_PORTS; >>>> priv->queue = -1; >>>> - strcpy(dev->name, "pow%d"); >>>> + strscpy(dev->name, "pow%d", sizeof(dev->name)); >>> >>> Is there a program which is generating a warning for this code? We know >>> that "pow%d" is 6 characters and static analysis tools can understand >>> this code fine so we know it's safe. >> >> Well I was confused too but checkpatch complained about >> it so I figured I'd clean it up quick > > Ah. It's a new checkpatch warning. I don't care in that case. I'm > fine with replacing all of these in that case. Alright thanks. Can you review this? Thanks, Sandro V