kdb: Replace deprecated strcpy() with strscpy()
PATCH 1/1 kdb: Replace deprecated strcpy() with strscpy()
strcpy() is deprecated; use strscpy() instead.
--- kernel/debug/kdb/kdb_support.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
kernel/debug/kdb/kdb_support.c +3 -1
@@ -23,6 +23,7 @@#include <linux/uaccess.h> #include <linux/kdb.h> #include <linux/slab.h> +#include <linux/string.h> #include <linux/ctype.h> #include "kdb_private.h"
@@ -250,7 +251,8 @@ char *kdb_strdup(const char *str, gfp_t type)char *s =kmalloc (n, type);if (!s)return NULL ; -return strcpy (s, str); +strscpy (s, str, n); +return s; }/*
Signature · 1 line
2.50.1
Hi,
Quoted 8 lines · Thorsten Blum
strcpy()is deprecated; usestrscpy()instead.Signed-off-by Thorsten Blum <[email protected]>--- kernel/debug/kdb/kdb_support.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
nit: Since this only covers things in the file kdb_support.c and not everything in kernel/debug/kdb, perhaps that should be in the subject line? Maybe "kdb: Replace deprecated strcpy() with strscpy() in kdb_strdup()"?
Other than that, this looks fine to me.
Hi Doug,
Quoted 10 lines · Doug Anderson
Quoted 8 lines · Thorsten Blum
strcpy()is deprecated; usestrscpy()instead.Signed-off-by Thorsten Blum <[email protected]>---
kernel/debug/kdb/kdb_support.c| 4 +++-1 file changed, 3 insertions(+), 1 deletion(-)
Quoted 8 lines
nit: Since this only covers things in the file
kdb_support.cand not everything inkernel/debug/kdb, perhaps that should be in the subject line? Maybe "kdb: Replace deprecatedstrcpy()withstrscpy()inkdb_strdup()"?Other than that, this looks fine to me.
Reviewed-by Douglas Anderson <[email protected]>
I'm preparing a patch series for Daniel with my kdb changes.
For this one here, I initially used:
strscpy(s, str, n); return s;
to replace 'return strcpy(s, str);', but now prefer:
memcpy(s, str, n); return s;
because we already know the string length 'n'.
Can I keep your Reviewed-by: tag when making this change and submitting it as part of a patch series?
Thanks,
Thorsten
Doug Anderson
reviewerHi,
Quoted 32 lines · Thorsten Blum
Hi Doug,
Quoted 10 lines · Doug Anderson
Quoted 8 lines · Thorsten Blum
strcpy()is deprecated; usestrscpy()instead.Signed-off-by Thorsten Blum <[email protected]>---
kernel/debug/kdb/kdb_support.c| 4 +++-1 file changed, 3 insertions(+), 1 deletion(-)Quoted 8 lines
nit: Since this only covers things in the file
kdb_support.cand not everything inkernel/debug/kdb, perhaps that should be in the subject line? Maybe "kdb: Replace deprecatedstrcpy()withstrscpy()inkdb_strdup()"?Other than that, this looks fine to me.
Reviewed-by Douglas Anderson <[email protected]>I'm preparing a patch series for Daniel with my kdb changes.
For this one here, I initially used:
strscpy(s, str, n); return s;to replace 'return
strcpy(s, str);', but now prefer:
Quoted 7 lines
memcpy(s, str, n); return s;because we already know the string length 'n'.
Can I keep your Reviewed-by: tag when making this change and submitting it as part of a patch series?
Sure.