[U-Boot] env: Avoid clobbering an edited variable on ctrl-c

Submitted by Joe Hershberger on Feb. 8, 2013, 8:12 p.m.

Details

Message ID 1360354355-32716-1-git-send-email-joe.hershberger@ni.com
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Joe Hershberger Feb. 8, 2013, 8:12 p.m.
If readline says there was an error, don't write to the variable!

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
---
 common/cmd_nvedit.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Tom Rini March 4, 2013, 9:27 p.m.
On Fri, Feb 08, 2013 at 10:12:34AM -0000, Joe Hershberger wrote:

> If readline says there was an error, don't write to the variable!
> 
> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>

Applied to u-boot/master, thanks!

Patch hide | download patch | download mbox

diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 7633f0c..063536b 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -552,7 +552,8 @@  static int do_env_edit(cmd_tbl_t *cmdtp, int flag, int argc,
 	else
 		buffer[0] = '\0';
 
-	readline_into_buffer("edit: ", buffer, 0);
+	if (readline_into_buffer("edit: ", buffer, 0) < 0)
+		return 1;
 
 	return setenv(argv[1], buffer);
 }