[linux-next] clocksource: Use strscpy() instead of strlcpy()

Message ID 20221020091312.398909-1-cui.jinpeng2@zte.com.cn
State New
Headers
Series [linux-next] clocksource: Use strscpy() instead of strlcpy() |

Commit Message

cuijinpeng666@gmail.com Oct. 20, 2022, 9:13 a.m. UTC
  From: Jinpeng Cui <cui.jinpeng2@zte.com.cn>

The implementation of strscpy() is more robust and safer.

Reported-by: Zeal Robot <zaelci@zte.com.cn>
Signed-off-by: Jinpeng Cui <cui.jinpeng2@zte.com.cn>
---
 kernel/time/clocksource.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Greg KH Oct. 20, 2022, 9:49 a.m. UTC | #1
On Thu, Oct 20, 2022 at 09:13:12AM +0000, cuijinpeng666@gmail.com wrote:
> From: Jinpeng Cui <cui.jinpeng2@zte.com.cn>
> 
> The implementation of strscpy() is more robust and safer.
> 
> Reported-by: Zeal Robot <zaelci@zte.com.cn>
> Signed-off-by: Jinpeng Cui <cui.jinpeng2@zte.com.cn>
> ---
>  kernel/time/clocksource.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)


Please ignore based on this response:
	https://lore.kernel.org/r/Y1EVnZS9BalesrC1@kroah.com
  

Patch

diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index dcaf38c06216..a3e7edfbb3c2 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -1461,7 +1461,7 @@  static int __init boot_override_clocksource(char* str)
 {
 	mutex_lock(&clocksource_mutex);
 	if (str)
-		strlcpy(override_name, str, sizeof(override_name));
+		strscpy(override_name, str, sizeof(override_name));
 	mutex_unlock(&clocksource_mutex);
 	return 1;
 }