From patchwork Mon Jan 9 11:45:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yang X-Patchwork-Id: 40813 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2108475wrt; Mon, 9 Jan 2023 03:49:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXsL7j+ct+ixc5p4IhrFqRzr5tziemgfFpmEcQ9Ivsm+PwxfAXOjJTwleRsqDmVKPIx80SGb X-Received: by 2002:a17:902:6ac3:b0:192:f5f3:4edf with SMTP id i3-20020a1709026ac300b00192f5f34edfmr16411693plt.38.1673264993938; Mon, 09 Jan 2023 03:49:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673264993; cv=none; d=google.com; s=arc-20160816; b=VAWb48OtSEbX99FEzsfHJ9bCcbeFwjJ3Y/vwnqUYnVneeNgqZL62c1jR7KXD95QX5k kcm3ToFKdQmlb/tBnpVjp7U7SgDBoifJ1FrXQ2u9k32joaMX4w+BDseQ0xhDlt7Yo4Yg sW5Upa9HV1I+b/VSeDQ6OXCw5lLzk7KSSk1Pn3aklRdrGjCRJa6CUD7cqWO2EUNh35Im IACdpufQvIT/53/vOkukuZcBdyKqbKrrgIjXPzZQOk2pquyMSRNGU+RnyYqVNYEObPdx 9fALuPuWmX8pi3hI8jbd1nL9RyeZiaaJ+GfDa4CgH8eZ1phKWf63utfdwgX//ldpts7P Tpgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:mime-version:message-id:date; bh=r9QtKw4MkZycSjNtMEoTxPG34xiIhQbRT5CqU+QDo9M=; b=qgO4MvRNDUUDqWLfrEQs9oTk/CnPgMP4uhOvJPcljYbrPFnt4/0nELVG7buQIH5hQO fEGDVZP2vfFZynbJJWtiFRvrTRayv3bFNvR5VQZwR6GMrbNbc8FWa9YCW9TL8Ymt3S5H IY47DlI42o30OFrGvWlWkPaiT5mHCVw1iKr8mcZfr1+ZLaWUJyfacujDg7shB0kju8fC 9Xoq77EAIC7EjYFPaqff24KJ0Hp9ArnYfekSG6QzSQKbyFBBnl5IpFM4BRSQk68kduEM WXbcAr/NUkHAJfEtNnTfo/izf6f3Yoif31YCW2ddIvRT5ooFns+5caC8Y10z4ojvosg6 ZQOg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jh19-20020a170903329300b00174ea015ee8si8216652plb.592.2023.01.09.03.49.41; Mon, 09 Jan 2023 03:49:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233686AbjAILqI (ORCPT + 99 others); Mon, 9 Jan 2023 06:46:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234245AbjAILp6 (ORCPT ); Mon, 9 Jan 2023 06:45:58 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 00824200B for ; Mon, 9 Jan 2023 03:45:56 -0800 (PST) Received: from mse-fl1.zte.com.cn (unknown [10.5.228.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxhk.zte.com.cn (FangMail) with ESMTPS id 4NrBwM51jlz6FK2T; Mon, 9 Jan 2023 19:45:55 +0800 (CST) Received: from szxlzmapp02.zte.com.cn ([10.5.231.79]) by mse-fl1.zte.com.cn with SMTP id 309Bjmri092787; Mon, 9 Jan 2023 19:45:48 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp01[null]) by mapi (Zmail) with MAPI id mid14; Mon, 9 Jan 2023 19:45:51 +0800 (CST) Date: Mon, 9 Jan 2023 19:45:51 +0800 (CST) X-Zmail-TransId: 2b0363bbfe6fffffffff89cdc856 X-Mailer: Zmail v1.0 Message-ID: <202301091945513559977@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , Subject: =?utf-8?q?=5BPATCH_linux-next=5D_ALSA=3A_control-led=3A_use_strscpy?= =?utf-8?q?=28=29_to_instead_of_strncpy=28=29?= X-MAIL: mse-fl1.zte.com.cn 309Bjmri092787 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.138.novalocal with ID 63BBFE73.000 by FangMail milter! X-FangMail-Envelope: 1673264755/4NrBwM51jlz6FK2T/63BBFE73.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63BBFE73.000/4NrBwM51jlz6FK2T X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754545514208728428?= X-GMAIL-MSGID: =?utf-8?q?1754545514208728428?= From: Xu Panda The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL-terminated strings. Signed-off-by: Xu Panda Signed-off-by: Yang Yang --- sound/core/control_led.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sound/core/control_led.c b/sound/core/control_led.c index f975cc85772b..c88653c205eb 100644 --- a/sound/core/control_led.c +++ b/sound/core/control_led.c @@ -534,8 +534,7 @@ static ssize_t set_led_id(struct snd_ctl_led_card *led_card, const char *buf, si struct snd_ctl_elem_id id; int err; - strncpy(buf2, buf, len); - buf2[len] = '\0'; + strncpy(buf2, buf, len + 1); memset(&id, 0, sizeof(id)); id.iface = SNDRV_CTL_ELEM_IFACE_MIXER; s = buf2;