Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5745097rwb; Mon, 5 Dec 2022 03:37:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf591pnq7VP1qEDlWHDY8mn1D+aS9d4+r4Eln8mspCCxGD0J+GgxNs/8CuIfK48kcRWDAn3m X-Received: by 2002:a17:90a:dd82:b0:212:fdb1:720b with SMTP id l2-20020a17090add8200b00212fdb1720bmr95184711pjv.66.1670240237534; Mon, 05 Dec 2022 03:37:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670240237; cv=none; d=google.com; s=arc-20160816; b=uo4prRUHjJDrv1HWH/b/yyhL09Yu0ElMHqyN1V0puEmNfRXREoV1VHsw2Ytwoq0ZFv JV77HU4TrRCPfmirL3/nwRntAD215ruJrk1Au9imOoZzp9Mv74yJYRkphtX4vzKA7tQA S8XwR+9dppQVCO0EngZMGEi6Q08fiENWTxxHJ5z3pded1HNSfi+VhAvIqOVwZeHfKTil 5gY1fHbQ3YwXKylRArG5bWvlOqMni4BGg1ArG23BeZq5pbfl5NJt1qj/bjTY+xR7aZLb nEbG++5eYpmq3DU39gXjKJGL2INyULBhketuN2MvlSV+nOrkltXbEyLVJ5J2WkdiaL4o U3cQ== 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=1NyMFNQ1aCVixUTMGBBgKHpBjfKKRfQLJPF7EsoCiik=; b=0Sj+5THcCFpsh6+qor+WQsKwtkCgwqDLTpknANuw9A9UXIS53yQGXFe0G5GTiAYeXm 7/FLTEdgjc3FcoVXdohwOidpWgXCa8MPy5cZT/EeaP+9WFsTLxVUuIs+KYEkkaXDEjl5 Hyw7CDwRyHCfNliOvV+jKaG/+40wn3PCNLhT3TI0ke5sqx5ZqzlLwb3Za3XFZKYhP55b HdspRlgtUYOnlvJRgtTnZGJdhhF+1UPMai/BwBJgL0wSgWeZYE6JemHgKklC71RJPw87 Fcy8sgWRN5+Zky3rXLxbFAtoRM7HB4kHgAhM0uCubDkJnFtD2Qrl3OOf4hlG4Mc7vS5s tkJg== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q33-20020a631f61000000b00476ef0d44f6si14498288pgm.672.2022.12.05.03.37.06; Mon, 05 Dec 2022 03:37:17 -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 S230348AbiLEL24 (ORCPT + 82 others); Mon, 5 Dec 2022 06:28:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229753AbiLEL2y (ORCPT ); Mon, 5 Dec 2022 06:28:54 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6241F10569 for ; Mon, 5 Dec 2022 03:28:53 -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 4NQhBr0D8xz4xVnH; Mon, 5 Dec 2022 19:28:52 +0800 (CST) Received: from szxlzmapp04.zte.com.cn ([10.5.231.166]) by mse-fl1.zte.com.cn with SMTP id 2B5BShdT045660; Mon, 5 Dec 2022 19:28:43 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp02[null]) by mapi (Zmail) with MAPI id mid14; Mon, 5 Dec 2022 19:28:46 +0800 (CST) Date: Mon, 5 Dec 2022 19:28:46 +0800 (CST) X-Zmail-TransId: 2b04638dd5ee1219271f X-Mailer: Zmail v1.0 Message-ID: <202212051928467539184@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHQgdjJdIGFjY2Vzc2liaWxpdHk6IHNwZWFrdXA6IHVzZSBzdHJzY3B5KCkgdG8gaW5zdGVhZCBvZiBzdHJuY3B5KCk=?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl1.zte.com.cn 2B5BShdT045660 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.138.novalocal with ID 638DD5F4.000 by FangMail milter! X-FangMail-Envelope: 1670239732/4NQhBr0D8xz4xVnH/638DD5F4.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 638DD5F4.000/4NQhBr0D8xz4xVnH 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 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 --- 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