[PATCH] setenv: be robust against setenv(<var>, NULL)

Peter Korsgaard jacmet at sunsite.dk
Sat May 14 16:33:51 EDT 2011


Handle value == NULL similiar to how value == '' is currently handled.
hush's builtin_getopt() seems to trigger this for OPTARG.

Signed-off-by: Peter Korsgaard <jacmet at sunsite.dk>
---
 common/env.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/common/env.c b/common/env.c
index b72b5d1..47cef05 100644
--- a/common/env.c
+++ b/common/env.c
@@ -205,7 +205,7 @@ int setenv(const char *_name, const char *value)
 	struct variable_d *var;
 	int ret = 0;
 
-	if (!*value)
+	if (value && !*value)
 		value = NULL;
 
 
-- 
1.7.4.4




More information about the barebox mailing list