Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp6651rwj; Thu, 22 Dec 2022 19:36:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXvOEqEdr3nwvugZyTrunXMDTWxS2F821bTnUwgSCxEL0cnUJHrXzKIU+23sL+IU7bIU8CMO X-Received: by 2002:aa7:9514:0:b0:57f:1da7:a781 with SMTP id b20-20020aa79514000000b0057f1da7a781mr9330530pfp.25.1671766574272; Thu, 22 Dec 2022 19:36:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671766574; cv=none; d=google.com; s=arc-20160816; b=drSCio1psHHdCbFUvhhiEIoEvKINfOEmzBpsfmVkpJtL5laVSL1kbub7rzFnKp5wQR lJPJPJ7sM9F7nV0dWbZHUwAlTjt27AA+vKzhw8yuWL0OzDQktPsMzuhmFhrjLeWsOYTt WHRbxACyxWvn8GeQrY5NuBTVkrUripcfGOZCkkgBbLqH5UecRC/mkT4gRoghV4gWEilf w985Nef4fwGjwjriAZZ0U2v44rfUc/HXnU406KTRpYIUyciH1F3HT1fOVnkgn5elUf0V ssyF9nQ+2FVrc8xTEIDK5h35V1o8kTaFQbLMkRwL1VSnh0hG+l9LvsbZvEeGuzzxMUlb LRtw== 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=bP7AzPOJnFKN6H4Z909TKLijDxHbwTExylghMZ5p04w=; b=v8nPGZQ9d2ieL1+SVniDTjE6rz5O2cu5bbGfq2RykAbHyZnLnpAJlbj+I4VMDJ3QoV c0y30jGbDOme9L3JcqQHzMApukUw1DtQzUHeJAysBGrMhFTvnZSTmIMET9XXfBDIKj1v wG+7awc9mgH527172uQMmzhvCuiLXtCYVwkrN3kTND8NVTg/rJDPyfNoWmakcOs+dxkd L2De+FXAPcPEGndL/1neWBkRlotDTrDQfV4N//u1/1h48rUOfY/WIEJC4Mvl+daAoWJB keW/loleMoRWUlRF6ZIjMMs1EgEcK37SV/u5vUwjyjLI4UQ01swnvMF0mADiDx9xq3Xa bIIg== 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 15-20020a630a0f000000b00477b463b049si2495331pgk.491.2022.12.22.19.36.05; Thu, 22 Dec 2022 19:36:14 -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 S235810AbiLWCoX (ORCPT + 67 others); Thu, 22 Dec 2022 21:44:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229524AbiLWCoV (ORCPT ); Thu, 22 Dec 2022 21:44:21 -0500 Received: from mxct.zte.com.cn (mxct.zte.com.cn [183.62.165.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3DA11BE93; Thu, 22 Dec 2022 18:44:20 -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 mxct.zte.com.cn (FangMail) with ESMTPS id 4NdWjH0chxz4y3ZP; Fri, 23 Dec 2022 10:44:19 +0800 (CST) Received: from szxlzmapp06.zte.com.cn ([10.5.230.252]) by mse-fl1.zte.com.cn with SMTP id 2BN2i9Jc072538; Fri, 23 Dec 2022 10:44:09 +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:44:10 +0800 (CST) Date: Fri, 23 Dec 2022 10:44:10 +0800 (CST) X-Zmail-TransId: 2b0463a515fa3ad9749c X-Mailer: Zmail v1.0 Message-ID: <202212231044105692444@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHRdIHJwbXNnOiB1c2Ugc3Ryc2NweSgpIHRvIGluc3RlYWQgb2Ygc3RybmNweSgp?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl1.zte.com.cn 2BN2i9Jc072538 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.251.13.novalocal with ID 63A51603.000 by FangMail milter! X-FangMail-Envelope: 1671763459/4NdWjH0chxz4y3ZP/63A51603.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63A51603.000/4NdWjH0chxz4y3ZP 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/rpmsg/rpmsg_ns.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/rpmsg/rpmsg_ns.c b/drivers/rpmsg/rpmsg_ns.c index c70ad03ff2e9..c7b5b60aef4d 100644 --- a/drivers/rpmsg/rpmsg_ns.c +++ b/drivers/rpmsg/rpmsg_ns.c @@ -48,9 +48,7 @@ static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, } /* don't trust the remote processor for null terminating the name */ - msg->name[RPMSG_NAME_SIZE - 1] = '\0'; - - strncpy(chinfo.name, msg->name, sizeof(chinfo.name)); + strscpy(chinfo.name, msg->name, sizeof(chinfo.name)); chinfo.src = RPMSG_ADDR_ANY; chinfo.dst = rpmsg32_to_cpu(rpdev, msg->addr); -- 2.15.2