kdb: kdb_support: replace strcpy() by strscpy()
authorGustavo A. R. Silva <gustavo@embeddedor.com>
Mon, 22 Apr 2019 16:21:06 +0000 (11:21 -0500)
committerDaniel Thompson <daniel.thompson@linaro.org>
Thu, 2 May 2019 12:42:01 +0000 (13:42 +0100)
The strcpy() function is being deprecated. Replace it by the safer
strscpy() and fix the following Coverity warning:

"You might overrun the 129-character fixed-size string ks_namebuf
by copying name without checking the length."

Addresses-Coverity-ID: 138995 ("Copy into fixed size buffer")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
kernel/debug/kdb/kdb_support.c

index 50bf9b119bad04952c767451a4e29315b0234ab0..b8e6306e7e133d452dad4c5e46e4753439d4b448 100644 (file)
@@ -192,7 +192,7 @@ int kallsyms_symbol_complete(char *prefix_name, int max_len)
 
        while ((name = kdb_walk_kallsyms(&pos))) {
                if (strncmp(name, prefix_name, prefix_len) == 0) {
-                       strcpy(ks_namebuf, name);
+                       strscpy(ks_namebuf, name, sizeof(ks_namebuf));
                        /* Work out the longest name that matches the prefix */
                        if (++number == 1) {
                                prev_len = min_t(int, max_len-1,