diff mbox

[U-Boot,1/1] common: nvedit: use snprintf instead of sprintf

Message ID 1450775655-2979-3-git-send-email-van.freenix@gmail.com
State Superseded
Headers show

Commit Message

Peng Fan Dec. 22, 2015, 9:14 a.m. UTC
From: Peng Fan <peng.fan@nxp.com>

Use snprintf to replace sprintf.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Joe Hershberger <joe.hershberger@ni.com>
---
 common/cmd_nvedit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Fabio Estevam Dec. 22, 2015, 9:53 a.m. UTC | #1
Hi Peng,

On Tue, Dec 22, 2015 at 7:14 AM, Peng Fan <van.freenix@gmail.com> wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> Use snprintf to replace sprintf.

You need to improve your commit log by saying why you are doing this change.
Joe Hershberger Dec. 22, 2015, 7:11 p.m. UTC | #2
On Tue, Dec 22, 2015 at 3:14 AM, Peng Fan <van.freenix@gmail.com> wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> Use snprintf to replace sprintf.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Joe Hershberger <joe.hershberger@ni.com>

Seems safer.
Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
Tom Rini Dec. 22, 2015, 7:40 p.m. UTC | #3
On Tue, Dec 22, 2015 at 07:53:12AM -0200, Fabio Estevam wrote:
> Hi Peng,
> 
> On Tue, Dec 22, 2015 at 7:14 AM, Peng Fan <van.freenix@gmail.com> wrote:
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > Use snprintf to replace sprintf.
> 
> You need to improve your commit log by saying why you are doing this change.


Yes, please do so.  And if you're using Coverity internally you can
still do a Reported-by: Coverity.
Peng Fan Dec. 23, 2015, 3 a.m. UTC | #4
Hi All,
On Tue, Dec 22, 2015 at 02:40:58PM -0500, Tom Rini wrote:
>On Tue, Dec 22, 2015 at 07:53:12AM -0200, Fabio Estevam wrote:
>> Hi Peng,
>> 
>> On Tue, Dec 22, 2015 at 7:14 AM, Peng Fan <van.freenix@gmail.com> wrote:
>> > From: Peng Fan <peng.fan@nxp.com>
>> >
>> > Use snprintf to replace sprintf.
>> 
>> You need to improve your commit log by saying why you are doing this change.

will add more commit log.
>
>
>Yes, please do so.  And if you're using Coverity internally you can
>still do a Reported-by: Coverity.
will add this.

Thanks,
Peng.


>
>-- 
>Tom
diff mbox

Patch

diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 2f9cdd0..5ae9d9d 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -595,7 +595,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';