Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp45237rwj; Thu, 22 Dec 2022 20:25:29 -0800 (PST) X-Google-Smtp-Source: AMrXdXvAeNu3zLnkTttZT1sFZWz+iyd37xeMVMCoycRKMeF8DQcoyXIFI6+Q3qCtRkb/Ky9Qujcr X-Received: by 2002:a05:6402:2a08:b0:470:4d71:6d43 with SMTP id ey8-20020a0564022a0800b004704d716d43mr7525790edb.25.1671769528915; Thu, 22 Dec 2022 20:25:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671769528; cv=none; d=google.com; s=arc-20160816; b=n9hJ1AYcrpb/Vm6Z5G+ECfPnp/HubFO7xI9uf7RoDIyZOVLlAtGO/Bou79fBI7Of/C HpZ53xQcFs2skpJk9JdLMZd0CQfqYQREYHws4wJt50vXa3sxdbfv3+/KN4nUWYx9npp8 Is672yPhZ6l7dMc3r/QK/7x06dUZTBF0SLbGxPOCN6PRqkw0LqvgzK60H3WgyF4T7riE 0hvdGpCKQM/r/wX0AmXgo3/kKRRQZmrj9v4olYqsX/BxyKxEJ7F9d4zck2QtoU7NbSks 99NX+npeVNe0EjOXI0Yf46YskBu2SvAhMhup5or5Jp4yOQVQ5k29SaRgvc00bTe2MD3R ky4Q== 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=Gsl9vmopu+Sx1tSnvLI7ireI9y0xFBWs4ozEmMSNkH4=; b=Uosv1LltF6+X4hsUguPkupqT6ygw5DBivT4dL5btjWvb6NRCSHNDYWVm4baXaeo+Q3 /thk+9hdwxWUCvucq1RGfXRU1ZCtiGphXUtXYDm5z5cubjPF+Gp0Vn0XFYkt816TW3WJ mgId2qlcB4pPzjtoLQ7CMGjIDI9Jx6qU96+oS1GzGepanllhmCdZPbvp0RIbQF5dY+tP fSUmKxU0lgBAr7u7BeTlpNZp9On+j5sfHE7wC86p2kvrT4vFWooKL/UJqKAr+aPNBBPN JlQWUBV/C8sfGZmB2uu09Nn83c5zQDJHU7rsRnLLIvnZIdByYNWnxaa/MpjE2B6ro9g+ mqyQ== 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 dy4-20020a05640231e400b004782d6f1286si1898315edb.516.2022.12.22.20.25.13; Thu, 22 Dec 2022 20:25:28 -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 S235740AbiLWClE (ORCPT + 67 others); Thu, 22 Dec 2022 21:41:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235374AbiLWClD (ORCPT ); Thu, 22 Dec 2022 21:41:03 -0500 Received: from mxhk.zte.com.cn (mxhk.zte.com.cn [63.216.63.35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 938211928A; Thu, 22 Dec 2022 18:41:02 -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 4NdWdT2kFBz4xVnK; Fri, 23 Dec 2022 10:41:01 +0800 (CST) Received: from szxlzmapp07.zte.com.cn ([10.5.230.251]) by mse-fl1.zte.com.cn with SMTP id 2BN2esCr070573; Fri, 23 Dec 2022 10:40:54 +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:40:56 +0800 (CST) Date: Fri, 23 Dec 2022 10:40:56 +0800 (CST) X-Zmail-TransId: 2b0463a515387568e84e X-Mailer: Zmail v1.0 Message-ID: <202212231040562072342@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHRdIHBhcmlzYzogdXNlIHN0cnNjcHkoKSB0byBpbnN0ZWFkIG9mIHN0cm5jcHkoKQ==?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl1.zte.com.cn 2BN2esCr070573 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.250.138.novalocal with ID 63A5153D.000 by FangMail milter! X-FangMail-Envelope: 1671763261/4NdWdT2kFBz4xVnK/63A5153D.000/10.5.228.132/[10.5.228.132]/mse-fl1.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63A5153D.000/4NdWdT2kFBz4xVnK 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/parisc/pdc_stable.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/parisc/pdc_stable.c b/drivers/parisc/pdc_stable.c index d6af5726ddf3..403bca0021c5 100644 --- a/drivers/parisc/pdc_stable.c +++ b/drivers/parisc/pdc_stable.c @@ -274,8 +274,7 @@ pdcspath_hwpath_write(struct pdcspath_entry *entry, const char *buf, size_t coun /* We'll use a local copy of buf */ count = min_t(size_t, count, sizeof(in)-1); - strncpy(in, buf, count); - in[count] = '\0'; + strscpy(in, buf, count + 1); /* Let's clean up the target. 0xff is a blank pattern */ memset(&hwpath, 0xff, sizeof(hwpath)); @@ -388,8 +387,7 @@ pdcspath_layer_write(struct pdcspath_entry *entry, const char *buf, size_t count /* We'll use a local copy of buf */ count = min_t(size_t, count, sizeof(in)-1); - strncpy(in, buf, count); - in[count] = '\0'; + strscpy(in, buf, count + 1); /* Let's clean up the target. 0 is a blank pattern */ memset(&layers, 0, sizeof(layers)); @@ -756,8 +754,7 @@ static ssize_t pdcs_auto_write(struct kobject *kobj, /* We'll use a local copy of buf */ count = min_t(size_t, count, sizeof(in)-1); - strncpy(in, buf, count); - in[count] = '\0'; + strscpy(in, buf, count + 1); /* Current flags are stored in primary boot path entry */ pathentry = &pdcspath_entry_primary; -- 2.15.2