Skip to contentSkip to conversation

common: nvedit: use snprintf instead of sprintf

PATCH New Peng Fan 2 participants 2 messages Dec 23, 2015 – Jan 4, 2016

lore
Share & tools
lore

Peng Fan

author
#0 lore raw

PATCH v2 1/1 common: nvedit: use snprintf instead of sprintf

From: Peng Fan <[email protected]>

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
Cc Tom Rini <[email protected]>
Cc Simon Glass <[email protected]>
---
 common/cmd_nvedit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/cmd_nvedit.c +1 -1
index f4c2523..3d295d1 100644
@@ -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';
 
Signature · 1 line
2.6.2
#1 lore raw

PATCH v2 1/1 common: nvedit: use snprintf instead of sprintf

Quoted 10 lines · Peng Fan

From: Peng Fan <[email protected]>

Use snprintf to replace sprintf.

Coverity log:
"
Unbounded source buffer (STRING_SIZE)
string_size: Passing string init_val of unknown size to sprintf. "

Quoted 5 lines
Reported-by Coverity
Cc Tom Rini <[email protected]>
Cc Simon Glass <[email protected]>

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160104/cbbeaf2a/attachment.sig>