Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp435849rdg; Thu, 12 Oct 2023 09:43:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHNOBuzi2zv2pYkzUp6OTUbfyJ7IgfQk7CKuyUna5XpgVLZSX5J7TwhDlbZ+ZmbvGEuhDrx X-Received: by 2002:a05:6a00:234a:b0:68f:b5a1:12bf with SMTP id j10-20020a056a00234a00b0068fb5a112bfmr29063698pfj.29.1697128982935; Thu, 12 Oct 2023 09:43:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697128982; cv=none; d=google.com; s=arc-20160816; b=y+SwzqKW2TzUv5y4tpKa67Z1yqDUNffOHtJVy4eAEpoiXxM45SeXpdDol9NbDSM2Tn JbyXs2TDs8F3bx3SaVcijiyvlhK0Lb+X6wf1hnQcp4rpSMa2pU5MBKARkYVdmeGnS3Fn bx1EXy7fe5OQfY/5+FXj+wpLVLzoQiiyRowTe8qaiAPbzSzIXRkLC2ssdG1243Yzdsz0 SkLLc+3OCgPIZgluV7lIJdOYbP2S1pFBzBipCJTq61eGZxYbInMpCeQyPJbNoYMIgPJP E+D73h1cjhBuMPbAoQzIqQIvPQXEFkI47oGDCC8QeLZ4+skmq6tikR85ow/2JFBPJBt3 AUnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=genJWKohyi+uw55PK14coV867Gc59Wliy9tyrnuTQVw=; fh=KLTb80zUFoadt0KbTLujBT1B5yEgMCeX4ueMGp71xDo=; b=sZH/G7/cs0ZBkV6aawFJEdR5Uljx2ZxSZo5Z3mTJXVumNhDpfh6Jt13najRMfFJpZp UmbbBjf3QPgRf8ITIZ37bpeOR1uLFyq9yx5IbWEGQzCjhe72h4BjAV75tR0Z5NDrQSsV ZOpsFbBEj3EPNpvrZCGqe5lJsUd/MgKIMAKZ9PHne/OI2aegdNkLRvqOGs1scrH0bBxY 2k8K9wOfWtBxGLMdDEZKwDJpgGev1P9ipRlhpXwsYT7e3659TP9I4KlUs7hnkS4ZQSt0 mEd8Pl6/jCefXd3OFA4cx/ymFOl3GEjLqIetzSQ8GbvptVfFlBMFd+dgSPN9Q5fmk+Iy lxQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=H3B1r42X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id p40-20020a056a000a2800b00686b62a6dc4si16193798pfh.145.2023.10.12.09.43.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 09:43:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=H3B1r42X; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 800718098FE0; Thu, 12 Oct 2023 09:43:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344029AbjJLQmx (ORCPT + 99 others); Thu, 12 Oct 2023 12:42:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233988AbjJLQmw (ORCPT ); Thu, 12 Oct 2023 12:42:52 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1363C0 for ; Thu, 12 Oct 2023 09:42:49 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BB8F4C433C8; Thu, 12 Oct 2023 16:42:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1697128969; bh=N7Ln3/7jFFi5dIEaPqUeVOm/valMyUNZ+yFVCH2HfD4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=H3B1r42Xk4qZTefHVM1u2WWTJtLS7u0LOelj+YTy6A7TaPA60KyCwYW65jmTQQNQ7 M8RsZax/OyV606kLidRx9BP0JMbKLlJ/wQ/nCGWAEw2hnDKICtHVigmW7ybQkbPxwW feJRadJVHz7PgVL7cTzM37Ifn8tO8KnEKX3jrPsM= Date: Thu, 12 Oct 2023 18:42:46 +0200 From: Greg Kroah-Hartman To: Calvince Otieno Cc: outreachy@lists.linux.dev, linux-kernel@vger.kernel.org, Archana , Dan Carpenter , Simon Horman , Bagas Sanjaya , linux-staging@lists.linux.dev Subject: Re: [PATCH v2] staging/wlan-ng: remove strcpy() use in favor of strscpy() Message-ID: <2023101234-extenuate-regain-2e36@gregkh> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 12 Oct 2023 09:43:00 -0700 (PDT) On Thu, Oct 12, 2023 at 05:01:57PM +0300, Calvince Otieno wrote: > In response to the suggestion by Dan Carpenter on the initial patch, > this patch provides a correct usage of the strscpy() in place of the > current strcpy() implementation. > > strscpy() copies characters from the source buffer to the destination > buffer until one of the following conditions is met: > - null-terminator ('\0') is encountered in the source string. > - specified maximum length of the destination buffer is reached. > - source buffer is exhausted. > Example: > char dest[11]; > const char *PRISM2_USB_FWFILE = "prism2_ru.fw"; > strscpy(dest, PRISM2_USB_FWFILE, sizeof(dest)); > > In this case, strscpy copies the first 10 characters of src into dest > and add a null-terminator. dest will then contain "prism2_ru.f" with > proper null-termination. > > Since the specified length of the dest buffer is not derived from the > dest buffer itself and rather form plug length (s3plug[i].len), > replacing strcpy() with strscpy() is a better option because it will > ensures that the destination string is always properly terminated. > > Signed-off-by: Calvince Otieno > --- > drivers/staging/wlan-ng/prism2fw.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c > index 5d03b2b9aab4..3ccd11041646 100644 > --- a/drivers/staging/wlan-ng/prism2fw.c > +++ b/drivers/staging/wlan-ng/prism2fw.c > @@ -725,7 +725,7 @@ static int plugimage(struct imgchunk *fchunk, unsigned int nfchunks, > > if (j == -1) { /* plug the filename */ > memset(dest, 0, s3plug[i].len); > - strncpy(dest, PRISM2_USB_FWFILE, s3plug[i].len - 1); > + strscpy(dest, PRISM2_USB_FWFILE, s3plug[i].len); > } else { /* plug a PDR */ > memcpy(dest, &pda->rec[j]->data, s3plug[i].len); > } > -- > 2.34.1 > > Hi, This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree. You are receiving this message because of the following common error(s) as indicated below: - This looks like a new version of a previously submitted patch, but you did not list below the --- line any changes from the previous version. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/process/submitting-patches.rst for what needs to be done here to properly describe this. If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers. thanks, greg k-h's patch email bot