Skip to contentSkip to conversation

common: cli_simple: use strlcpy instead of strcpy

PATCH New Peng Fan 3 participants 3 messages Jan 10, 2016 – Jan 14, 2016

lore
Share & tools
lore

Peng Fan

author
#0 lore raw

PATCH v2 1/1 common: cli_simple: use strlcpy instead of strcpy

Report Coverity log:
Destination buffer too small (STRING_OVERFLOW)
string_overflow: You might overrun the 1024 byte destination string lastcommand by writing 1025 bytes from console_buffer

Cc Heiko Schocher <[email protected]>
Cc Simon Glass <[email protected]>
Cc Tom Rini <[email protected]>

---

Changes V2:
Use strlcpy instead of strncpy.

 common/cli_simple.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
common/cli_simple.c +2 -1
index 9c3d073..bb96aae 100644
@@ -276,7 +276,8 @@ void cli_simple_loop(void)
 
 		flag = 0;	/* assume no special flags for now */
 		if (len > 0)
-			strcpy(lastcommand, console_buffer);
+			strlcpy(lastcommand, console_buffer,
+				CONFIG_SYS_CBSIZE + 1);
 		else if (len == 0)
 			flag |= CMD_FLAG_REPEAT;
 #ifdef CONFIG_BOOT_RETRY_TIME
Signature · 1 line
2.6.2
#1 lore raw

PATCH v2 1/1 common: cli_simple: use strlcpy instead of strcpy

Quoted 9 lines · Peng Fan

Report Coverity log:
Destination buffer too small (STRING_OVERFLOW)
string_overflow: You might overrun the 1024 byte destination string lastcommand by writing 1025 bytes from console_buffer

Cc Heiko Schocher <[email protected]>
Cc Simon Glass <[email protected]>
Cc Tom Rini <[email protected]>
Quoted 7 lines

---

Changes V2:
Use strlcpy instead of strncpy.

 common/cli_simple.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
#2 lore raw

PATCH v2 1/1 common: cli_simple: use strlcpy instead of strcpy

In reply to Peng Fan
Quoted 10 lines · Peng Fan

Report Coverity log:
Destination buffer too small (STRING_OVERFLOW)
string_overflow: You might overrun the 1024 byte destination string lastcommand by writing 1025 bytes from console_buffer

Cc Heiko Schocher <[email protected]>
Cc Simon Glass <[email protected]>
Cc Tom Rini <[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/20160114/b0a0cd07/attachment.sig>