diff options
author | Kees Cook <kees@kernel.org> | 2024-07-11 09:54:32 -0700 |
---|---|---|
committer | Shuah Khan <skhan@linuxfoundation.org> | 2024-07-12 10:11:48 -0600 |
commit | 7554a7b96dc0dcc445d4af7077c96c6ab0988c79 (patch) | |
tree | bcd0d2c6b0ed34392dfc15f22f6aea58e7b26ef7 /lib/kunit/executor_test.c | |
parent | 67c9971cd6d309ecbcb87b942e22ffc194d7a376 (diff) |
kunit: executor: Simplify string allocation handling
The alloc/copy code pattern is better consolidated to single kstrdup (and
kstrndup) calls instead. This gets rid of deprecated[1] strncpy() uses as
well. Replace one other strncpy() use with the more idiomatic strscpy().
Link: https://github.com/KSPP/linux/issues/90 [1]
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Kees Cook <kees@kernel.org>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'lib/kunit/executor_test.c')
-rw-r--r-- | lib/kunit/executor_test.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/kunit/executor_test.c b/lib/kunit/executor_test.c index 3f7f967e3688..f0090c2729cd 100644 --- a/lib/kunit/executor_test.c +++ b/lib/kunit/executor_test.c @@ -286,7 +286,7 @@ static struct kunit_suite *alloc_fake_suite(struct kunit *test, /* We normally never expect to allocate suites, hence the non-const cast. */ suite = kunit_kzalloc(test, sizeof(*suite), GFP_KERNEL); - strncpy((char *)suite->name, suite_name, sizeof(suite->name) - 1); + strscpy((char *)suite->name, suite_name, sizeof(suite->name)); suite->test_cases = test_cases; return suite; |