Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5854086rwb; Mon, 5 Dec 2022 05:08:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf6yUs8gvZ7BkfzOPy9WRE7rMlDvUR48umuylyTGaWsXbyLunDu6w+HnZP3OEAHEeFL0jYgj X-Received: by 2002:a05:6a00:84d:b0:56d:5709:a03e with SMTP id q13-20020a056a00084d00b0056d5709a03emr85263617pfk.23.1670245698820; Mon, 05 Dec 2022 05:08:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670245698; cv=none; d=google.com; s=arc-20160816; b=rDVKowDtjulerThUa268G2Vfyhy7vpNpdSnoKJC9AzXDB2gKZ0XmoNn0Bd26y4ZH6Z S8sVpu+JNyKijvzzKUdSC3iLBeph1EwkBoZ/q3Bsrf+fOjrOi4O7YTZKnPIYUTPDARkQ AcK90mbPwOfHaLrRCDx5wSrDurU6cGpS+MN6IrpfxXnHr3YR9fQE3u++U+iIoxyN4wtn uvuL0YMFBGiZ9xByeC/avXl3N+1X9h9zZYGoYY8TLHNqa2O/wSddjJ3WTIuAwAuc5N9p 43Xwu/X9X5XkH5oDelJQXLQ+t8zfbISB2kwiCpn2UJZT71hntaQqv0X3gN17Pu38E3Ob 2EQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:organization:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date; bh=QIL71K6vN94XBvF+ssiIWIgBZBYHbRG+sQa5sBpaQLU=; b=FbzoZYw6p37iyMXAtbfkYiFblRVo7IPkyQVaBkj9EPHMwW/x6dKUDnUKVax6rgfiyn sS06fbhBl0SA9v1ApJoTukg1ryR8zPvwdJ9UAxN4EgklDDW+MNfTnvDx1PajG7crEj2q PGePqPrSz6RcQY9lUIyKe08xW3zH3/mOkyWTJBNb65uQdZBRGDlmaZh5RjIb+slmgSXl Nxf9igDB1j4vI7nzg1O5jK7fHm7XooE6DHdZhwL1N+PM1/EQ3C9cU/+OOgKLJPLskf/6 POlLQGvGn7nbS+jyvVpXJ97XmNi2f2Gx5S/lZWDuBf4UvOzPOI7mCXyFKjI06nJZN7dM UKbQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c15-20020a17090a1d0f00b002196afcdfc8si13096307pjd.96.2022.12.05.05.08.05; Mon, 05 Dec 2022 05:08:18 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231774AbiLEMhd (ORCPT + 82 others); Mon, 5 Dec 2022 07:37:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230084AbiLEMha (ORCPT ); Mon, 5 Dec 2022 07:37:30 -0500 Received: from sonata.ens-lyon.org (domu-toccata.ens-lyon.fr [140.77.166.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADFC117887 for ; Mon, 5 Dec 2022 04:37:29 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 832542010B; Mon, 5 Dec 2022 13:37:27 +0100 (CET) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 34QAqrD_xFx3; Mon, 5 Dec 2022 13:37:27 +0100 (CET) Received: from begin (nat-inria-interne-52-gw-01-bso.bordeaux.inria.fr [194.199.1.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id BDA1720108; Mon, 5 Dec 2022 13:37:26 +0100 (CET) Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1p2Air-00293E-30; Mon, 05 Dec 2022 13:37:25 +0100 Date: Mon, 5 Dec 2022 13:37:25 +0100 From: Samuel Thibault To: yang.yang29@zte.com.cn Cc: w.d.hubbs@gmail.com, chris@the-brannons.com, kirk@reisers.ca, mushi.shar@gmail.com, speakup@linux-speakup.org, linux-kernel@vger.kernel.org, xu.panda@zte.com.cn Subject: Re: [PATCH linux-next v2] accessibility: speakup: use strscpy() to instead of strncpy() Message-ID: <20221205123725.jn6gdimypvzcj5zg@begin> Mail-Followup-To: Samuel Thibault , yang.yang29@zte.com.cn, w.d.hubbs@gmail.com, chris@the-brannons.com, kirk@reisers.ca, mushi.shar@gmail.com, speakup@linux-speakup.org, linux-kernel@vger.kernel.org, xu.panda@zte.com.cn References: <202212051928467539184@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202212051928467539184@zte.com.cn> Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_PASS 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 yang.yang29@zte.com.cn, le lun. 05 déc. 2022 19:28:46 +0800, a ecrit: > From: Xu Panda > > The implementation of strscpy() is more robust and safer. > That's now the recommended way to copy NUL terminated strings. > --- > change for v2 > - fix the mistake of eating one character when len > 250, > thanks to Samuel Thibault. > --- > > Signed-off-by: Xu Panda > Signed-off-by: Yang Yang > Signed-off-by: Samuel Thibault It's not really a signed-off from my side, I just did a review :) but with that version, Reviewed-by: Samuel Thibault > --- > drivers/accessibility/speakup/kobjects.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/accessibility/speakup/kobjects.c b/drivers/accessibility/speakup/kobjects.c > index a7522d409802..c1ef48280f3c 100644 > --- a/drivers/accessibility/speakup/kobjects.c > +++ b/drivers/accessibility/speakup/kobjects.c > @@ -426,8 +426,7 @@ static ssize_t synth_direct_store(struct kobject *kobj, > spin_lock_irqsave(&speakup_info.spinlock, flags); > while (len > 0) { > bytes = min_t(size_t, len, 250); > - strncpy(tmp, ptr, bytes); > - tmp[bytes] = '\0'; > + strscpy(tmp, ptr, bytes + 1); > string_unescape_any_inplace(tmp); > synth_printf("%s", tmp); > ptr += bytes; > -- > 2.15.2 > -- Samuel --- Pour une évaluation indépendante, transparente et rigoureuse ! Je soutiens la Commission d'Évaluation de l'Inria.