[lxc-devel] [PATCH 4/6] coverity: Check return value of setenv

Stéphane Graber stgraber at ubuntu.com
Fri Feb 14 21:33:07 UTC 2014


Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
 src/lxc/attach.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/lxc/attach.c b/src/lxc/attach.c
index 8782652..28cf916 100644
--- a/src/lxc/attach.c
+++ b/src/lxc/attach.c
@@ -317,8 +317,10 @@ static int lxc_attach_set_environment(enum lxc_attach_env_policy_t policy, char*
 		if (extra_keep_store) {
 			size_t i;
 			for (i = 0; extra_keep[i]; i++) {
-				if (extra_keep_store[i])
-					setenv(extra_keep[i], extra_keep_store[i], 1);
+				if (extra_keep_store[i]) {
+					if (setenv(extra_keep[i], extra_keep_store[i], 1) < 0)
+						SYSERROR("Unable to set environment variable");
+				}
 				free(extra_keep_store[i]);
 			}
 			free(extra_keep_store);
-- 
1.9.rc1



More information about the lxc-devel mailing list