From nobody Mon Sep 15 23:17:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47C83C54EBD for ; Mon, 9 Jan 2023 11:41:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233624AbjAILlN (ORCPT ); Mon, 9 Jan 2023 06:41:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237012AbjAILku (ORCPT ); Mon, 9 Jan 2023 06:40:50 -0500 Received: from mxct.zte.com.cn (mxct.zte.com.cn [183.62.165.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2747BB36; Mon, 9 Jan 2023 03:40:47 -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 4NrBpP5TMYz4y3Z2; Mon, 9 Jan 2023 19:40:45 +0800 (CST) Received: from szxlzmapp04.zte.com.cn ([10.5.231.166]) by mse-fl1.zte.com.cn with SMTP id 309BeefP089112; Mon, 9 Jan 2023 19:40:40 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp01[null]) by mapi (Zmail) with MAPI id mid14; Mon, 9 Jan 2023 19:40:43 +0800 (CST) Date: Mon, 9 Jan 2023 19:40:43 +0800 (CST) X-Zmail-TransId: 2b0363bbfd3b029d1fed X-Mailer: Zmail v1.0 Message-ID: <202301091940437129873@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHRdIHhmczogdXNlIHN0cnNjcHkoKSB0byBpbnN0ZWFkIG9mIHN0cm5jcHkoKQ==?= X-MAIL: mse-fl1.zte.com.cn 309BeefP089112 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.251.13.novalocal with ID 63BBFD3D.000 by FangMail milter! X-FangMail-Envelope: 1673264445/4NrBpP5TMYz4y3Z2/63BBFD3D.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63BBFD3D.000/4NrBpP5TMYz4y3Z2 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_xattr.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c index 10aa1fd39d2b..913c1794bc2f 100644 --- a/fs/xfs/xfs_xattr.c +++ b/fs/xfs/xfs_xattr.c @@ -212,9 +212,7 @@ __xfs_xattr_put_listent( offset =3D context->buffer + context->count; memcpy(offset, prefix, prefix_len); offset +=3D prefix_len; - strncpy(offset, (char *)name, namelen); /* real name */ - offset +=3D namelen; - *offset =3D '\0'; + strscpy(offset, (char *)name, namelen + 1); /* real name */ compute_size: context->count +=3D prefix_len + namelen + 1; --=20 2.15.2