aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schlemmer <azarah@gentoo.org>2006-07-06 16:44:48 +0000
committerMartin Schlemmer <azarah@gentoo.org>2006-07-06 16:44:48 +0000
commit5c23d11155525708bc894d02e9986d5e0732030e (patch)
tree95afdb5c55cc5d6e13b5f2ff65e977eecf0c0614
parentSet default values via a config file. Also support sandbox.d (diff)
downloadsandbox-5c23d11155525708bc894d02e9986d5e0732030e.tar.gz
sandbox-5c23d11155525708bc894d02e9986d5e0732030e.tar.bz2
sandbox-5c23d11155525708bc894d02e9986d5e0732030e.zip
Free some of our custom environment data.
Signed-off-by: Martin Schlemmer <azarah@gentoo.org>
-rw-r--r--src/sandbox.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/sandbox.c b/src/sandbox.c
index 027301e..f49bf8e 100644
--- a/src/sandbox.c
+++ b/src/sandbox.c
@@ -449,8 +449,6 @@ char **sandbox_setup_environ(struct sandbox_info_t *sandbox_info, bool interacti
have_ld_preload = 1;
orig_ld_preload_envvar = getenv(ENV_LD_PRELOAD);
- /* FIXME: Should probably free this at some stage - more neatness
- * than a real leak that will cause issues. */
ld_preload_envvar = calloc(strlen(orig_ld_preload_envvar) +
strlen(sandbox_info->sandbox_lib) + 2,
sizeof(char *));
@@ -460,8 +458,6 @@ char **sandbox_setup_environ(struct sandbox_info_t *sandbox_info, bool interacti
strlen(sandbox_info->sandbox_lib) + 2, "%s %s",
sandbox_info->sandbox_lib, orig_ld_preload_envvar);
} else {
- /* FIXME: Should probably free this at some stage - more neatness
- * than a real leak that will cause issues. */
ld_preload_envvar = rc_strndup(sandbox_info->sandbox_lib,
strlen(sandbox_info->sandbox_lib));
if (NULL == ld_preload_envvar)
@@ -479,7 +475,7 @@ char **sandbox_setup_environ(struct sandbox_info_t *sandbox_info, bool interacti
* a real leak that will cause issues. */
new_environ = calloc((env_size + 15 + 1) * sizeof(char *), sizeof(char *));
if (NULL == new_environ)
- return NULL;
+ goto error;
snprintf(sb_pid, sizeof(sb_pid), "%i", getpid());
@@ -538,7 +534,16 @@ char **sandbox_setup_environ(struct sandbox_info_t *sandbox_info, bool interacti
env_ptr++;
}
+ if (NULL != ld_preload_envvar)
+ free(ld_preload_envvar);
+
return new_environ;
+
+error:
+ if (NULL != ld_preload_envvar)
+ free(ld_preload_envvar);
+
+ return NULL;
}
int spawn_shell(char *argv_bash[], char *env[], int debug)
@@ -692,6 +697,9 @@ int main(int argc, char **argv)
if (!spawn_shell(argv_bash, sandbox_environ, print_debug))
success = 0;
+ /* Free environ */
+ free(sandbox_environ);
+
/* Free bash stuff */
for (i = 0; i < 6; i++) {
if (argv_bash[i])