kcsan: test: Replace deprecated strcpy() with strscpy()
PATCH 1/1 kcsan: test: Replace deprecated strcpy() with strscpy()
strcpy() is deprecated; use strscpy() instead.
--- kernel/kcsan/kcsan_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/kcsan/kcsan_test.c +2 -2
@@ -125,7 +125,7 @@ static void probe_console(void *ignore, const char *buf, size_t len) goto out;/* No second line of interest. */ -strcpy (observed.lines[nlines++],"<none>" ); +strscpy (observed.lines[nlines++],"<none>" ); } }
@@ -231,7 +231,7 @@ static bool __report_matches(const struct expect_report *r)if (!r->access[1 ].fn) {/* Dummy string if no second access is available. */ -strcpy (cur,"<none>" ); +strscpy (expect[2 ],"<none>" );break ; } }
Signature · 1 line
2.50.1
Hi,
Quoted 13 lines · Thorsten Blum
strcpy()is deprecated; usestrscpy()instead.Signed-off-by Thorsten Blum <[email protected]>--- kernel/kcsan/kcsan_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)kernel/kcsan/kcsan_test.c +0
-0
kernel/kcsan/kcsan_test.c static void probe_console(void *ignore, const char *buf, size_t len) · line 128
Quoted 5 lines
kernel/kcsan/kcsan_test.c +1
-1@@ -125,7 +125,7 @@ static void probe_console(void *ignore, const char *buf, size_t len) goto out;/* No second line of interest. */ -strcpy (observed.lines[nlines++],"<none>" ); +strscpy (observed.lines[nlines++],"<none>" );
Looks good.
Here's my checklist:
1) strcpy() and strscpy() have differing return values, but we aren't using it.
2) strscpy() can fail with -E2BIG if source is too big, but it isn't in this case.
3) two-arg version of strscpy() is OK to use here as the source has a known size at compile time.
Quoted 16 lines
kernel/kcsan/kcsan_test.c +1
-1} }@@ -231,7 +231,7 @@ static bool __report_matches(const struct expect_report *r)if (!r->access[1 ].fn) {/* Dummy string if no second access is available. */ -strcpy (cur,"<none>" ); +strscpy (expect[2 ],"<none>" );break ; } }Signature · 1 line
2.50.1
Thanks
Justin
Quoted 11 lines · Justin Stitt
Looks good.
Here's my checklist:
1)strcpy()andstrscpy()have differing return values, but we aren't using it.
2)strscpy()can fail with-E2BIGif source is too big, but it isn't in this case.
3) two-arg version ofstrscpy()is OK to use here as the source has a known size at compile time.Reviewed-by Justin Stitt <[email protected]>
Thanks for your thorough review.
Thorsten
Quoted 5 lines · Thorsten Blum
strcpy()is deprecated; usestrscpy()instead.Signed-off-by Thorsten Blum <[email protected]>
Taking this into the -kcsan tree, but might be a while until it hits mainline.
Quoted 33 lines
--- kernel/kcsan/kcsan_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)kernel/kcsan/kcsan_test.c +2
-3@@ -125,7 +125,7 @@ static void probe_console(void *ignore, const char *buf, size_t len) goto out;/* No second line of interest. */ -strcpy (observed.lines[nlines++],"<none>" ); +strscpy (observed.lines[nlines++],"<none>" ); } }@@ -231,7 +231,7 @@ static bool __report_matches(const struct expect_report *r)if (!r->access[1 ].fn) {/* Dummy string if no second access is available. */ -strcpy (cur,"<none>" ); +strscpy (expect[2 ],"<none>" );break ; } } --2.50.1
--
You received this message because you are subscribed to the Google Groups "kasan-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/kasan-dev/20250815213742.321911-3-thorsten.blum%40linux.dev.