Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

staging: most: use format specifier "%s" in snprintf

Passing string ch_data_type[i].name as the format specifier is
potentially hazardous because it could (although very unlikely to)
have a format specifier embedded in it causing issues when parsing
the non-existent arguments to these. Follow best practice by using
the "%s" format string for the string.

Cleans up clang warning:
format string is not a string literal (potentially insecure) [-Wformat-security]

Fixes: e7f2b70fd3a9 ("staging: most: replace multiple if..else with table lookup")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Colin Ian King and committed by
Greg Kroah-Hartman
13c45007 c948c691

+1 -1
+1 -1
drivers/staging/most/core.c
··· 351 351 352 352 for (i = 0; i < ARRAY_SIZE(ch_data_type); i++) { 353 353 if (c->cfg.data_type & ch_data_type[i].most_ch_data_type) 354 - return snprintf(buf, PAGE_SIZE, ch_data_type[i].name); 354 + return snprintf(buf, PAGE_SIZE, "%s", ch_data_type[i].name); 355 355 } 356 356 return snprintf(buf, PAGE_SIZE, "unconfigured\n"); 357 357 }