[U-Boot] [PATCH V2] common: nvedit: use snprintf instead of sprintf
Peng Fan
van.freenix at gmail.com
Wed Dec 23 05:08:09 CET 2015
From: Peng Fan <peng.fan at nxp.com>
Use snprintf to replace sprintf.
Coverity log:
"
Unbounded source buffer (STRING_SIZE)
string_size: Passing string init_val of unknown size to sprintf.
"
Reported-by: Coverity
Signed-off-by: Peng Fan <peng.fan at nxp.com>
Cc: Tom Rini <trini at konsulko.com>
Cc: Simon Glass <sjg at chromium.org>
Reviewed-by: Joe Hershberger <joe.hershberger at ni.com>
---
common/cmd_nvedit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index f4c2523..3d295d1 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -594,7 +594,7 @@ static int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc,
/* Set read buffer to initial value or empty sting */
init_val = getenv(argv[1]);
if (init_val)
- sprintf(buffer, "%s", init_val);
+ snprintf(buffer, CONFIG_SYS_CBSIZE, "%s", init_val);
else
buffer[0] = '\0';
--
2.6.2
More information about the U-Boot
mailing list