Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp112006rwb; Tue, 6 Dec 2022 18:06:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf4XL9WKUiBNuIqhc1T2az46cJziaR0gDYh01aEWTcxbDMh0ZaKCX5prP+WdbfPyZqMfb0m7 X-Received: by 2002:a17:903:3011:b0:189:ac81:54d3 with SMTP id o17-20020a170903301100b00189ac8154d3mr32209713pla.130.1670378809291; Tue, 06 Dec 2022 18:06:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670378809; cv=none; d=google.com; s=arc-20160816; b=xlgl9AZioHD9KCjdBa+eEaOy9VPGGZNu8DVxLC+QT/SNTJxqGOQ9qGcL6KT2DwObeW sZIx7KDJDWD+5z42zNXZf7Ur1Ks5HaFd02Vgr1jGhzTuvcmtMNZB3QHdswpTQ2sITiAU M2pbfEdRrP0Mn3MhoerxTnNl1Wd/EJA9JdzJ2TptV/wdy4wRd0RoOOTwLOMfVwCrIuum VsmjbbKZCevRa13TcRX9wbeyuCfPT+ayxagI8KmvtRBgeCGGNx198fCB9Hcy4QCW4R0G TYtQ2lMVqTEewv5+0sPNsjimPq5OfbDBpHt4Pdhf9iI7HqV5kMmri5HBYFszNAzunCQ0 kLNg== 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=jutZhDeYx1LUTZriJaEd89G8/YNZyWx0rytJ1ocDRbE=; b=EaiLnAYguDRo3nl2ubvO9LieUD/+91kgxLvtVLdOhXgYSstgsTJv5GRn5mqsbpLUyc YAR8v5aLi7W2CK7V8tEIaLpPcPa1jJPbjqI324qzlGxrUxLpkHFeqBDguFlE6prY146P 0VGz43nggBtYkCtfWtGcjNlrxTRd2QwNw6iIcm9St+hAHHf6HIPSVC6CKOQgnriybyPF jDhS+GEWKd2N4UwSfl8IQyLrEfKUoFNFFdGlGnPQu3FrKhEzlD7tGikapmrRag5oIxQ+ Dp5akjti/eMSusD8+NA4zutmxjnSIQiI4UeqDfiboBXF2UyK+SrgqC77t9frNkDa5NPv 8u1Q== 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 c19-20020a631c13000000b0046154b597cfsi13237210pgc.565.2022.12.06.18.06.18; Tue, 06 Dec 2022 18:06:49 -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 S229758AbiLGBJq (ORCPT + 77 others); Tue, 6 Dec 2022 20:09:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229737AbiLGBJe (ORCPT ); Tue, 6 Dec 2022 20:09:34 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEABB60E7; Tue, 6 Dec 2022 17:09:32 -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 mxhk.zte.com.cn (FangMail) with ESMTPS id 4NRfMH0SZrz8RV7G; Wed, 7 Dec 2022 09:09:31 +0800 (CST) Received: from szxlzmapp05.zte.com.cn ([10.5.230.85]) by mse-fl2.zte.com.cn with SMTP id 2B71984p063121; Wed, 7 Dec 2022 09:09:08 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp02[null]) by mapi (Zmail) with MAPI id mid14; Wed, 7 Dec 2022 09:09:09 +0800 (CST) Date: Wed, 7 Dec 2022 09:09:09 +0800 (CST) X-Zmail-TransId: 2b04638fe7b575b72e87 X-Mailer: Zmail v1.0 Message-ID: <202212070909095189693@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , , , , , , , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHRdIGNhbjogdWNhbjogdXNlIHN0cnNjcHkoKSB0byBpbnN0ZWFkIG9mIHN0cm5jcHkoKQ==?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl2.zte.com.cn 2B71984p063121 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.137.novalocal with ID 638FE7CB.000 by FangMail milter! X-FangMail-Envelope: 1670375371/4NRfMH0SZrz8RV7G/638FE7CB.000/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 638FE7CB.000/4NRfMH0SZrz8RV7G X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, 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/net/can/usb/ucan.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/can/usb/ucan.c b/drivers/net/can/usb/ucan.c index ffa38f533c35..159e25ffa337 100644 --- a/drivers/net/can/usb/ucan.c +++ b/drivers/net/can/usb/ucan.c @@ -1534,9 +1534,8 @@ static int ucan_probe(struct usb_interface *intf, sizeof(union ucan_ctl_payload)); if (ret > 0) { /* copy string while ensuring zero termination */ - strncpy(firmware_str, up->ctl_msg_buffer->raw, - sizeof(union ucan_ctl_payload)); - firmware_str[sizeof(union ucan_ctl_payload)] = '\0'; + strscpy(firmware_str, up->ctl_msg_buffer->raw, + sizeof(union ucan_ctl_payload) + 1); } else { strcpy(firmware_str, "unknown"); } -- 2.15.2