Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp9470rwj; Thu, 22 Dec 2022 19:39:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXt3VJXMcCCvOiVPbEyF0NOJJA9ido9FdbEuaF+1EnW9zMz7dSGn1SbeMIIFymNRKJV2qa4E X-Received: by 2002:a17:90a:1b44:b0:223:b1e3:997f with SMTP id q62-20020a17090a1b4400b00223b1e3997fmr9191035pjq.48.1671766794651; Thu, 22 Dec 2022 19:39:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671766794; cv=none; d=google.com; s=arc-20160816; b=GbtOyxXnQKi/jPeItK6GYXHynxCdGmbONWmy3+o1S6eYmmh9dKEi+pwWQX9nMuNbwt +6nB3Q1C7FDqnjI15P+0MZnshD/I4SXGG2Tv9kFqW6KzBvj1Ub9Jkv4xL72EjIjQtaZJ JUK4lBRSNPb7/tgr0DIoO6gxRVzMRIenbx+Ei/kMVseE7xWOLI+7WQpeDGGiO0PZJ0qy mzl5xy3y31mbvYm39MoEWtz+gmWBoy8HHXYfHb9PSbAXxfOKTvKEtdhQ+RX4JGu4ARVO yzzSD2iILUi1fY9tnjIghOz4sgpvuITOtr1xqu8NQahBwen/DXeoMzC/lOGQkmnGJ9/z UjHw== 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=zLtT/QwjyP16Ie87DJ7T4HSh5tXcuV0bAsv+RbL6Se4=; b=0UZVbFA4zzZ5o+qQ3Cx4WxHDlY7SU8kTifFIc95OSW+AKkJc7WlTXsayWTZYv1IGYr Zd1wF8ddpR4zv10hkfUjz/SKCMblYc8OA1yjmbKTb1a+C0xi+p036mPBb2ZiVjhpB5xc lqSjzg74atHmsscMr2m6DmLq+2PmV/XqoIDcNC8iJSn4+bDbfhWZ5Q4hwnY1ATZrzruu pEt0auttb6etTVas00ToH2jiasOUGXdYU1F62ocpij6MwWFdOuepQ3lQ1MdPK7G3V7Aq AWDvTXKqwcpwhGrsS/Ga/ieNxDvZPShRP5PNguJ0oQMy4wBYnKLxFjV2/bpo2iDI53BT YI9Q== 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 kb4-20020a17090ae7c400b00223c0bc663dsi2984861pjb.146.2022.12.22.19.39.24; Thu, 22 Dec 2022 19:39:54 -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 S235782AbiLWCj1 (ORCPT + 67 others); Thu, 22 Dec 2022 21:39:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42244 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235711AbiLWCjZ (ORCPT ); Thu, 22 Dec 2022 21:39:25 -0500 Received: from mxct.zte.com.cn (mxct.zte.com.cn [183.62.165.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C2AD1928A; Thu, 22 Dec 2022 18:39:22 -0800 (PST) Received: from mse-fl2.zte.com.cn (unknown [10.5.228.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxct.zte.com.cn (FangMail) with ESMTPS id 4NdWbW5qJkz4y3ZH; Fri, 23 Dec 2022 10:39:19 +0800 (CST) Received: from szxlzmapp07.zte.com.cn ([10.5.230.251]) by mse-fl2.zte.com.cn with SMTP id 2BN2dBSU049421; Fri, 23 Dec 2022 10:39:11 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp02[null]) by mapi (Zmail) with MAPI id mid14; Fri, 23 Dec 2022 10:39:12 +0800 (CST) Date: Fri, 23 Dec 2022 10:39:12 +0800 (CST) X-Zmail-TransId: 2b0463a514d02fd8a3f9 X-Mailer: Zmail v1.0 Message-ID: <202212231039128402297@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHRdIG9mOiBiYXNlOiB1c2Ugc3Ryc2NweSgpIHRvIGluc3RlYWQgb2Ygc3RybmNweSgp?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl2.zte.com.cn 2BN2dBSU049421 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.251.13.novalocal with ID 63A514D7.001 by FangMail milter! X-FangMail-Envelope: 1671763159/4NdWbW5qJkz4y3ZH/63A514D7.001/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63A514D7.001/4NdWbW5qJkz4y3ZH 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. Signed-off-by: Xu Panda Signed-off-by: Yang Yang --- drivers/of/base.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index d5a5c35eba72..ac6fde53342f 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1884,8 +1884,7 @@ static void of_alias_add(struct alias_prop *ap, struct device_node *np, { ap->np = np; ap->id = id; - strncpy(ap->stem, stem, stem_len); - ap->stem[stem_len] = 0; + strscpy(ap->stem, stem, stem_len + 1); list_add_tail(&ap->link, &aliases_lookup); pr_debug("adding DT alias:%s: stem=%s id=%i node=%pOF\n", ap->alias, ap->stem, ap->id, np); -- 2.15.2