Skip to content

Commit 70867ef

Browse files
arndbDaniel Thompson
authored andcommitted
kdb: address -Wformat-security warnings
When -Wformat-security is not disabled, using a string pointer as a format causes a warning: kernel/debug/kdb/kdb_io.c: In function 'kdb_read': kernel/debug/kdb/kdb_io.c:365:36: error: format not a string literal and no format arguments [-Werror=format-security] 365 | kdb_printf(kdb_prompt_str); | ^~~~~~~~~~~~~~ kernel/debug/kdb/kdb_io.c: In function 'kdb_getstr': kernel/debug/kdb/kdb_io.c:456:20: error: format not a string literal and no format arguments [-Werror=format-security] 456 | kdb_printf(kdb_prompt_str); | ^~~~~~~~~~~~~~ Use an explcit "%s" format instead. Signed-off-by: Arnd Bergmann <[email protected]> Fixes: 5d5314d ("kdb: core for kgdb back end (1 of 2)") Reviewed-by: Douglas Anderson <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Thompson <[email protected]>
1 parent 6ba59ff commit 70867ef

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/debug/kdb/kdb_io.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ static char *kdb_read(char *buffer, size_t bufsize)
362362
if (i >= dtab_count)
363363
kdb_printf("...");
364364
kdb_printf("\n");
365-
kdb_printf(kdb_prompt_str);
365+
kdb_printf("%s", kdb_prompt_str);
366366
kdb_printf("%s", buffer);
367367
if (cp != lastchar)
368368
kdb_position_cursor(kdb_prompt_str, buffer, cp);
@@ -453,7 +453,7 @@ char *kdb_getstr(char *buffer, size_t bufsize, const char *prompt)
453453
{
454454
if (prompt && kdb_prompt_str != prompt)
455455
strscpy(kdb_prompt_str, prompt, CMD_BUFLEN);
456-
kdb_printf(kdb_prompt_str);
456+
kdb_printf("%s", kdb_prompt_str);
457457
kdb_nextline = 1; /* Prompt and input resets line number */
458458
return kdb_read(buffer, bufsize);
459459
}

0 commit comments

Comments
 (0)