[PATCH 3/4] commands: nv: pass empty string for nv

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Setting a variable via the nv command results in the call chain
nvar_add() -> nv_save() -> __nv_save().

__nv_save isn't supposed to be called with val=NULL argument however:

	dprintf(fd, "%s", val);

Avoid this from happening by translating NULL into the empty string.
This aligns nv with the behavior of hush and setenv (but not global,
this will need to be looked at separately).

Signed-off-by: Ahmad Fatoum <ahmad@xxxxxx>
---
 commands/nv.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/commands/nv.c b/commands/nv.c
index fa865811dce2..a1cff08ee463 100644
--- a/commands/nv.c
+++ b/commands/nv.c
@@ -59,6 +59,8 @@ static int do_nv(int argc, char *argv[])
 		if (value) {
 			*value = 0;
 			value++;
+		} else {
+			value = "";
 		}
 
 		if (do_remove) {
-- 
2.28.0


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux