Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3461209rwb; Sat, 3 Dec 2022 05:25:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf6mCHdZuBDMmbNsogl03mkyMFwEFaO3BExhO3Gf3kT7TigePoecpTfcuC8r+ZCDK3D1ZlTm X-Received: by 2002:a17:902:6b89:b0:188:bb79:4892 with SMTP id p9-20020a1709026b8900b00188bb794892mr58556298plk.60.1670073908772; Sat, 03 Dec 2022 05:25:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670073908; cv=none; d=google.com; s=arc-20160816; b=0r3fXPUPjDr35Pf0X9oOnIMGkdx3F6Wx6qv1Mni638hDyFhzJl7xovfg6/b8Uf2p+n hfFATp4+ejj4oi5eGBKdRgikj0ltYimBAKG0edtsyHz9B/jomPVEFy6kqYnLO/KqZ44B +gnvL+FjcswONoaUEmTEwXlDh8inQXh6HZpsy/y+BNOoeWFtT7rnA3QBuJHUfT+0xL// X0wkGBAoTaZyXbcJYROShXi36TjqhtB7FNa3AIcS6lT1L4YoqeCIbnOMPXS81PtX/AFR Q91rjj3W5hdhz99bhPhecW1YtfPj+RTS0dihtcMQx7cuvKlqHQVo5NlkTXgT1xhwGFXB dOBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=OrAUu7Ff3xgokUXDmmKP6mhi/0QSxx1iup4Fo4DXL7o=; b=zTX138At4AtaihqSoZtDmXQb9Ok1MqX6OrW/TB0IsusqHKWdhgwVKzI3i66oniFSbU x+Ar4CDCQAKARymNJHu3mlYPmx7TYzwkH2KaI7OIVYtk2rBYzhgt1UV1gFe0IaRDaXin 5K1h2KNLaLFCjNHkyWlpv2X8740AXm3xGJ66dJjgHD4uknvxXeu8vtleiJZOZ1qZk0j5 +I7lAvy5Cl5P5HirxHfMRl1FRbN8/4y79Gy1wH368RYBOAN2QsAi2G9qTiOmAh28uxZd siFdTqlCN/GOJmEBI5BpSQiykKv3/Xn7oA20X748+1xMYe4bTAbM2++zJ4nWlKDdg17V bINQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="O/Cc03u8"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t8-20020a056a00138800b005728c05ef9esi10898478pfg.14.2022.12.03.05.24.56; Sat, 03 Dec 2022 05:25:08 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b="O/Cc03u8"; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229691AbiLCMTo (ORCPT + 82 others); Sat, 3 Dec 2022 07:19:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229481AbiLCMTj (ORCPT ); Sat, 3 Dec 2022 07:19:39 -0500 Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 187351A39C; Sat, 3 Dec 2022 04:19:38 -0800 (PST) Received: by mail-qv1-xf30.google.com with SMTP id mn15so5144722qvb.13; Sat, 03 Dec 2022 04:19:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=OrAUu7Ff3xgokUXDmmKP6mhi/0QSxx1iup4Fo4DXL7o=; b=O/Cc03u8Z1p5p75/IwB6FdLM/KSdWwo9G6jO010hcbWdiTwpbCC9fl5eSHek1fSw+a uSIlk++1rziLI9fNPXpuNnvposE/kN+sQKTymXKT0FFISwZW21/HFAgZWmsl8tPXVeyq 9wZstA4V7Xb5SxRSgkUi8d+bn45EBaI/MIEtPNNRLCSB2HyKDPubqM5yURWL18V8dgcd 3DXDWzH4Y/BCAnNoaj8tk1txh73zQKlyDENwfkMnWGI3ooWNQGrGKn+3hItuDdZmT/Pz M34OU3+xCHlz8IR09dPg47LjEaoRl+ktEaiai7x9UoLWQFMcMCtTbPrKOwxI/LwZSkas I13A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OrAUu7Ff3xgokUXDmmKP6mhi/0QSxx1iup4Fo4DXL7o=; b=cgXcmSgTBj+u7FuXzhrp0wKGskZdze4CnB7+ox3OYSzy2+PLbbd6QpUqxQFJcRrhGG 5V0nHgfXhHvmp4MSNJnJcwR4ejMyzBqJGW86YvH9qKNDZNKTEy5OIpthicEWW2yOaLyl Sq8J/UIRjNKm6Sdb5YIlL3kaJIOcme5GH3JAk4e5M3ehmsNCWW10Ys0FiBu2Db6Lm1cT tDQ0oVbKkYeLuYC18s1G2ayzpbGEFBsjEsAqK+XioHNHk0nF5wGpX/s2sRhZ8lETwQIh WlBHarcu7VP+sxdJCfbvLmRHVAxcIFvwpsDw1FkY+zgdJR9LoTtz6Xs+nyXPIl3XMR8i qWdg== X-Gm-Message-State: ANoB5pkGWNM4Qc7wWuOu87jyib28aTyDHkKlS/UesRZiQgQZz/MGUxu9 enu3wu73y2Q0K6g9dddm0zwlZ3zIL6SE1ejWIac= X-Received: by 2002:ad4:57aa:0:b0:4c6:f83c:4741 with SMTP id g10-20020ad457aa000000b004c6f83c4741mr29888828qvx.11.1670069977099; Sat, 03 Dec 2022 04:19:37 -0800 (PST) MIME-Version: 1.0 References: <202212031424175433783@zte.com.cn> In-Reply-To: From: Andy Shevchenko Date: Sat, 3 Dec 2022 14:19:01 +0200 Message-ID: Subject: Re: [PATCH linux-next] x86/platform/uv: use strscpy to instead of strncpy() To: yang.yang29@zte.com.cn Cc: steve.wahl@hpe.com, mike.travis@hpe.com, dimitri.sivanich@hpe.com, russ.anderson@hpe.com, dvhart@infradead.org, andy@infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, xu.panda@zte.com.cn Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 On Sat, Dec 3, 2022 at 2:15 PM Andy Shevchenko wrote: > On Sat, Dec 3, 2022 at 8:24 AM wrote: ... > > /* (remove possible '\n') */ > > - strncpy(arg, val, ACTION_LEN - 1); > > - arg[ACTION_LEN - 1] = '\0'; > > + strscpy(arg, val, ACTION_LEN - 1); > > Should be ACTION_LEN here, no? > > > p = strchr(arg, '\n'); > > if (p) > > *p = '\0'; > > Wouldn't be better to refactor this > > p = strnchrnul(val, ACTION_LEN, '\n'); > strscpy(arg, val, p - val); Or even drop p completely strscpy(arg, val, strnchrnul(val, ACTION_LEN, '\n') - val); -- With Best Regards, Andy Shevchenko