Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp6063304rwl; Mon, 9 Jan 2023 03:51:25 -0800 (PST) X-Google-Smtp-Source: AMrXdXvhPNuoA9nKc9FNFMKmHQNpE34Cp5J/LhG1tfiJ+1klEDz1jgWtjPNsyi5aEZbZ7ExyOoRR X-Received: by 2002:a05:6a20:47c6:b0:b0:1e9b:e930 with SMTP id ey6-20020a056a2047c600b000b01e9be930mr69872720pzb.57.1673265085428; Mon, 09 Jan 2023 03:51:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673265085; cv=none; d=google.com; s=arc-20160816; b=HhBhURHDqdQDLHNtkepEvicKym01ZBfC+tr438XFS6aLVbA21lSkjO1N6zzl8BElNu mc6SWuv7FW8lFrOz13ykHvP4ZgniY9lr9LdtI+NpnX9DE3bfkliJfvBozPQxolyyAea+ 1Jc1DEfjZXg12BWN+g0GGjZpp9ZvhVcND5/ORleSgnHOiFBuhPO7hB8OwxA3XW0tI2D8 FwsEsoqZl6z1ZLrOkMYFKg6i4b7pb4ARFjIJ6Ic+KpISrupkVgCVrswGK3qd4dLW36Sm L6phcZPRWApOLgnGL6/8p4U0lfq6ioTw/53rQicuyiW4b6Nq8seuLd55MRBq89s6BMc/ V/sg== 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=dAENBolQvIxVlrwq6KnikUabrDZPTj2EZawts2dh1Zw=; b=grqwTjDdPAsT8M3CRMraTTOcKnxgTbieOwCvaj0nkBnRBTg/+A7gxFC6bgCbRQpe54 mXaS9WRmdHLb2EC6c91KpNA3A0BFKaE2ptWJTqBe0dWadtyqSMb/KJcREI643wggqLL8 ddRGOOopEbjg8w5DcoAC6hGD8qjUFbfNvNS/2c+/G/FEHtnLWBvB6PdkUGrYViKPoIi4 tndod/cXX0o5fE6UYp0dnWsoA4mw0kZATJ7Tas0YEBoY06arR+ulDd+HpjdpqzpAX1Ea ws/fg09JqmgmMV5FQ/z2Bu1nVYhcEcAQy2xG/UcvYVhFQL7rD2GYacpcWVsTb2EKJxpD TO4g== 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 l186-20020a6388c3000000b00479018afb14si9980654pgd.49.2023.01.09.03.51.18; Mon, 09 Jan 2023 03:51:25 -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 S229865AbjAILlJ (ORCPT + 53 others); Mon, 9 Jan 2023 06:41:09 -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==?= Content-Type: text/plain; charset="UTF-8" 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 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 --- 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 = context->buffer + context->count; memcpy(offset, prefix, prefix_len); offset += prefix_len; - strncpy(offset, (char *)name, namelen); /* real name */ - offset += namelen; - *offset = '\0'; + strscpy(offset, (char *)name, namelen + 1); /* real name */ compute_size: context->count += prefix_len + namelen + 1; -- 2.15.2