Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp2853194pxb; Mon, 6 Sep 2021 06:51:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfNa600MHwej8jvVrFVajs2Gj3laypdvcs58EyICAeeDOtZNbVU6NxaFKcNepwsT+ImMrZ X-Received: by 2002:a92:3f0b:: with SMTP id m11mr8159375ila.265.1630936282774; Mon, 06 Sep 2021 06:51:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630936282; cv=none; d=google.com; s=arc-20160816; b=KLJa87LldNPGxSaAwLASFeDf3FRvTlATZjNX8Dzujusv2xcUm8EbtbAObfBS8/LSuO TVly3KJzLDIWFxwLwBKVp0wduoDxme9RGEoKNJQUfR1Yi5b+AXmS9TB9CS85GQJHoI6K aPZYlQRw2CFcB+mtloTeFF0+JgkVnEGGCQ/ospfOIPxkejIkp/s1FpjJTHSdMTN/om5V qvH2kRgszSTFWgWhw02PerdQ6UbGZExFQ4uC+4l6V0UZneAusX23xDLeQ2HifkoxrCd3 ZJPrFYS0Z84oayvmpouBkmNXu6PtfRQczwg73RdGlqJKS0aFr1MgfxlwakYHAh6hSvOQ EBWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=dEyKdGg+m7GxIZjhQJWXC/cpY4QKgHrJL2NzJ4e7uGg=; b=XkM1qVgd2E25os78R/S3CEHO6cRoAoH/xuBPnuDBv6UT8ZR9u3owqew0yvOwvs2P9s aHoMU4Hn6D5pjLqI8tvw1uOGgUzugfqoLEaJYpJPp5aXCU4qNwHYkH5LGsRMZ6HZlF9G Yn4Q7G0P7xaos64pY044uQOUQ/mqFyrkU5Wpb6qs1loszJNRfsUvdRHfzrzpgMI+PlPG FlT59/EiYE0nljMeoatpnXImu+CpNb/O1FVXFN+tlgY+U69CefZes9q0yeDuofnx9+32 EfkJeIiMXJ+ngNJM6JsHPZaXQfFVtwugPULTzgAOTxnd8Go634DKd/7N5m/hl5rR5P95 kV+Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p14si9067958iov.81.2021.09.06.06.51.10; Mon, 06 Sep 2021 06:51:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242854AbhIFNss (ORCPT + 99 others); Mon, 6 Sep 2021 09:48:48 -0400 Received: from smtpbg126.qq.com ([106.55.201.22]:17264 "EHLO smtpbg587.qq.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S242330AbhIFNss (ORCPT ); Mon, 6 Sep 2021 09:48:48 -0400 X-QQ-mid: bizesmtp32t1630936019t1xc7n3c Received: from localhost.localdomain (unknown [171.223.98.107]) by esmtp6.qq.com (ESMTP) with id ; Mon, 06 Sep 2021 21:46:58 +0800 (CST) X-QQ-SSF: 01000000004000C0D000B00A0000000 X-QQ-FEAT: 0VmwRkEgV1FWcRSAALeydNZuGmmRQOvfXre6MvYzyVi1tkDn5Cdgidi1shKhC Sknu6ZAyCKbDkD7bhCk4DUrSVQWEWwZ/1tMhR00TDwWO46mldUDlTSUNAgX9zJJwfBGTBkU sPy52KRAoeMhK+psazlvQl7L7gSG05rhgy40VmG0ySByUhWVgZaKxnUqI2/HITYeuggXlcY ehYW7X98Am2kPVE9HWoBXyB0ZURRZuZLJts5a1zb7r6FSEpu+qFAtTCBR90rAKgj8zgQdHN sRxfqxY7Y1PFGscAvyn5mQJi8zDlJNQlmV5glWW5j9lgTwiYgwuOmHdu90jmDCiMijwXmrX ANE6jGtwghATq3QHn2N/266Qki2DA== X-QQ-GoodBg: 0 From: Jason Wang To: krzysztof.kozlowski@canonical.com Cc: linux@armlinux.org.uk, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Jason Wang Subject: [PATCH] ARM: s3c: Use strscpy to replace strlcpy Date: Mon, 6 Sep 2021 21:46:56 +0800 Message-Id: <20210906134656.101088-1-wangborong@cdjrlc.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:cdjrlc.com:qybgspam:qybgspam2 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The strlcpy should not be used because it doesn't limit the source length. As linus says, it's a completely useless function if you can't implicitly trust the source string - but that is almost always why people think they should use it! All in all the BSD function will lead some potential bugs. But the strscpy doesn't require reading memory from the src string beyond the specified "count" bytes, and since the return value is easier to error-check than strlcpy()'s. In addition, the implementation is robust to the string changing out from underneath it, unlike the current strlcpy() implementation. Thus, We prefer using strscpy instead of strlcpy. Signed-off-by: Jason Wang --- arch/arm/mach-s3c/mach-mini6410.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-s3c/mach-mini6410.c b/arch/arm/mach-s3c/mach-mini6410.c index 741fa1f09694..c14c2e27127b 100644 --- a/arch/arm/mach-s3c/mach-mini6410.c +++ b/arch/arm/mach-s3c/mach-mini6410.c @@ -262,7 +262,7 @@ static char mini6410_features_str[12] __initdata = "0"; static int __init mini6410_features_setup(char *str) { if (str) - strlcpy(mini6410_features_str, str, + strscpy(mini6410_features_str, str, sizeof(mini6410_features_str)); return 1; } -- 2.33.0