Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp76324rwb; Tue, 6 Dec 2022 17:31:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf7q6F39r3pP7MvUteBW31/+Io6q+J9eEj4VVGcKpM9f7zQHZ8J6ep6j5bF40Qgk5dVyG2fJ X-Received: by 2002:a05:6402:5010:b0:467:60bd:41a1 with SMTP id p16-20020a056402501000b0046760bd41a1mr80733779eda.97.1670376705663; Tue, 06 Dec 2022 17:31:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670376705; cv=none; d=google.com; s=arc-20160816; b=dAIdTTZDwFXIk2tm9qd4yySjGk5UsoqlVKKezzX4b/iSLUH9IWTdN79BqcdUgchRZD UB6IKAKHDMfmqICpJ97D58UuySdkngBgN/d/5YPMv+aIGa74MUFu+BsYbWU4ph26Fii9 +x5ztTlPLe7ZRlP078C1tP6xYa4AEbz1/4UXHXkwxBU4bcFmpbBXVjKUoRl4o0un12hE 4Ix3gGDm5Jgl35ilG/C8gZvGcM7jV3zUVZbep3YvTtB6A+IkGBnommiCKemxYTQFrpuf B+/bQJ2/KV+XPxHy/5keCkYWyGuF8Iq6jrYmwcmz+j3u2twDxC1Ebm8LpB6z54c0bh1w o6ag== 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=igTSLt/yJRWfVoFPjZqtyau1Z5PRKYe7hJIhnygHO1M=; b=LEEhjeTLG+Y06o89Du32gDScL9oikMlkI1dIPsdYvLpqL9pBq3D+hOliAty1rptatb SoBcqllu+HaqrQMLqld23XK7Ql1IC8IWaTAvt+40QKn0VGoMu8CaCjCGOQo6GYPOoqr8 siE+ddeJ2sBL5IW9HBiAOlvZTwwJaxIbjMegNlGMStZH21A57r3TnBvmeYgq2UX3OmCJ BuNXmNiAcZyYJM0rjFJWwN8tPk+Uy8r6p5iz3MJlP1DLjzDP363cBlTEQGwHiJbHFiYb ah2q619h8qWzGL5PFszmbrZm9sY/E/Q2CDbCvCkxUwpKxutpI86+JGJeT6i3t5l5rwF5 I/ag== 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 eh17-20020a0564020f9100b00469dd6e394asi2739902edb.579.2022.12.06.17.31.26; Tue, 06 Dec 2022 17:31:45 -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 S229744AbiLGBOk (ORCPT + 78 others); Tue, 6 Dec 2022 20:14:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229670AbiLGBOj (ORCPT ); Tue, 6 Dec 2022 20:14:39 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B4434C25C for ; Tue, 6 Dec 2022 17:14:38 -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 4NRfT92XxWz4xVnK; Wed, 7 Dec 2022 09:14:37 +0800 (CST) Received: from szxlzmapp04.zte.com.cn ([10.5.231.166]) by mse-fl1.zte.com.cn with SMTP id 2B71EN5C058547; Wed, 7 Dec 2022 09:14:23 +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:14:24 +0800 (CST) Date: Wed, 7 Dec 2022 09:14:24 +0800 (CST) X-Zmail-TransId: 2b04638fe8f0ffffffff9ff87117 X-Mailer: Zmail v1.0 Message-ID: <202212070914242210002@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHRdIG1pc2M6IGVlcHJvbS9pZHRfODlocGVzeDogdXNlIHN0cnNjcHkoKSB0byBpbnN0ZWFkIG9mCiBzdHJuY3B5KCnCoA==?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl1.zte.com.cn 2B71EN5C058547 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.138.novalocal with ID 638FE8FD.000 by FangMail milter! X-FangMail-Envelope: 1670375677/4NRfT92XxWz4xVnK/638FE8FD.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 638FE8FD.000/4NRfT92XxWz4xVnK 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/misc/eeprom/idt_89hpesx.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/misc/eeprom/idt_89hpesx.c b/drivers/misc/eeprom/idt_89hpesx.c index 4e07ee9cb500..57b985fe59f4 100644 --- a/drivers/misc/eeprom/idt_89hpesx.c +++ b/drivers/misc/eeprom/idt_89hpesx.c @@ -941,8 +941,7 @@ static ssize_t idt_dbgfs_csr_write(struct file *filep, const char __user *ubuf, goto free_buf; } /* Copy the register address to the substring buffer */ - strncpy(csraddr_str, buf, csraddr_len); - csraddr_str[csraddr_len] = '\0'; + strscpy(csraddr_str, buf, csraddr_len + 1); /* Register value must follow the colon */ csrval_str = colon_ch + 1; } else /* if (str_colon == NULL) */ { -- 2.15.2