From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E62A1C54EBD for ; Mon, 9 Jan 2023 12:41:01 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id F400DB7E5; Mon, 9 Jan 2023 13:40:08 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz F400DB7E5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1673268059; bh=gBLqGIRRcXtCWYqfynqiecPv57mqUcM1uLzQkomaZAU=; h=Date:From:To:Subject:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: Cc:From; b=NNidVubvewEq+vi7cbS+wUDpbMwIX391STWSnf5JgrKT9usL0hh4QiL6rZJxCVgng r/hC/TZst3EhiFAgZZ6asrcnGKmpQW6eeQbTsGo4xLYV9Y6X3M9mEjX50byVKphqUj aXWejDEh9aGyaEb1bPiucVPWhN6WOP3XOITvqbSg= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 74BD0F802BE; Mon, 9 Jan 2023 13:40:08 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id D1299F8030F; Mon, 9 Jan 2023 13:40:06 +0100 (CET) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id E2472F80245 for ; Mon, 9 Jan 2023 13:40:04 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz E2472F80245 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key, unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256 header.s=susede2_rsa header.b=fGejd6PQ; dkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256 header.s=susede2_ed25519 header.b=3bPOQPsB Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7BC933EEC4; Mon, 9 Jan 2023 12:40:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1673268003; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=sxdz8WLO9DUBROFb+jBWHE2Tj51r6kudSkohQSadqZs=; b=fGejd6PQVFdhK0EKMTdcf/XrJRdgIHXx5WerdJY7xq/6Flxe9nPcwL7bSf4bCSXkCyK+ok 8fbkvb5bV67dUuJSiqKKsGTTINJ0kJkS72qo4WrAVM1DhCp7AF1ZSaGz0p0wwJvqQDHJhb Wux3CVZ0NEGBYdFqf8KCPXgbcwzRiS8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1673268003; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=sxdz8WLO9DUBROFb+jBWHE2Tj51r6kudSkohQSadqZs=; b=3bPOQPsBJjln7pGcBCINy//eU5+06X7eZpfoE9TO/IpAfWiUC7lhd9a9cfIXLU6tN6kcmt IdViUO9CGYrcvSDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4800F13583; Mon, 9 Jan 2023 12:40:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id voZnECMLvGNZbgAAMHmgww (envelope-from ); Mon, 09 Jan 2023 12:40:03 +0000 Date: Mon, 09 Jan 2023 13:40:02 +0100 Message-ID: <87zgarg9ul.wl-tiwai@suse.de> From: Takashi Iwai To: Subject: Re: [PATCH linux-next] ALSA: control-led: use strscpy() to instead of strncpy() In-Reply-To: <202301091945513559977@zte.com.cn> References: <202301091945513559977@zte.com.cn> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, xu.panda@zte.com.cn, tiwai@suse.com Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Mon, 09 Jan 2023 12:45:51 +0100, wrote: > > 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); Still using strncpy()...? thanks, Takashi From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28C1EC5479D for ; Mon, 9 Jan 2023 12:40:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234613AbjAIMkI (ORCPT ); Mon, 9 Jan 2023 07:40:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231591AbjAIMkG (ORCPT ); Mon, 9 Jan 2023 07:40:06 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E15EEE29 for ; Mon, 9 Jan 2023 04:40:05 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7BC933EEC4; Mon, 9 Jan 2023 12:40:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1673268003; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=sxdz8WLO9DUBROFb+jBWHE2Tj51r6kudSkohQSadqZs=; b=fGejd6PQVFdhK0EKMTdcf/XrJRdgIHXx5WerdJY7xq/6Flxe9nPcwL7bSf4bCSXkCyK+ok 8fbkvb5bV67dUuJSiqKKsGTTINJ0kJkS72qo4WrAVM1DhCp7AF1ZSaGz0p0wwJvqQDHJhb Wux3CVZ0NEGBYdFqf8KCPXgbcwzRiS8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1673268003; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=sxdz8WLO9DUBROFb+jBWHE2Tj51r6kudSkohQSadqZs=; b=3bPOQPsBJjln7pGcBCINy//eU5+06X7eZpfoE9TO/IpAfWiUC7lhd9a9cfIXLU6tN6kcmt IdViUO9CGYrcvSDg== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 4800F13583; Mon, 9 Jan 2023 12:40:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id voZnECMLvGNZbgAAMHmgww (envelope-from ); Mon, 09 Jan 2023 12:40:03 +0000 Date: Mon, 09 Jan 2023 13:40:02 +0100 Message-ID: <87zgarg9ul.wl-tiwai@suse.de> From: Takashi Iwai To: Cc: , , , , Subject: Re: [PATCH linux-next] ALSA: control-led: use strscpy() to instead of strncpy() In-Reply-To: <202301091945513559977@zte.com.cn> References: <202301091945513559977@zte.com.cn> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 09 Jan 2023 12:45:51 +0100, wrote: > > 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); Still using strncpy()...? thanks, Takashi