/[path-sandbox]/trunk/src/sandbox.c
Gentoo

Diff of /trunk/src/sandbox.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 93 Revision 96
275 275
276 while (NULL != *tmp_env) 276 while (NULL != *tmp_env)
277 tmp_env++; 277 tmp_env++;
278 278
279 /* strlen(name) + strlen(val) + '=' + '\0' */ 279 /* strlen(name) + strlen(val) + '=' + '\0' */
280 /* FIXME: Should probably free this at some stage - more neatness than
281 * a real leak that will cause issues. */
280 tmp_string = calloc(strlen(name) + strlen(val) + 2, sizeof(char *)); 282 tmp_string = calloc(strlen(name) + strlen(val) + 2, sizeof(char *));
281 if (NULL == tmp_string) { 283 if (NULL == tmp_string) {
282 perror(">>> out of memory (sandbox_setenv)"); 284 perror(">>> out of memory (sandbox_setenv)");
283 exit(1); 285 exit(1);
284 } 286 }
308 unsetenv(ENV_SANDBOX_BASHRC); 310 unsetenv(ENV_SANDBOX_BASHRC);
309 unsetenv(ENV_SANDBOX_LOG); 311 unsetenv(ENV_SANDBOX_LOG);
310 unsetenv(ENV_SANDBOX_DEBUG_LOG); 312 unsetenv(ENV_SANDBOX_DEBUG_LOG);
311 313
312 if (NULL != getenv("LD_PRELOAD")) { 314 if (NULL != getenv("LD_PRELOAD")) {
315 /* FIXME: Should probably free this at some stage - more neatness
316 * than a real leak that will cause issues. */
313 ld_preload_envvar = malloc(strlen(getenv("LD_PRELOAD")) + 317 ld_preload_envvar = malloc(strlen(getenv("LD_PRELOAD")) +
314 strlen(sandbox_lib) + 2); 318 strlen(sandbox_lib) + 2);
315 if (NULL == ld_preload_envvar) 319 if (NULL == ld_preload_envvar)
316 return NULL; 320 return NULL;
317 strncpy(ld_preload_envvar, sandbox_lib, strlen(sandbox_lib)); 321 strncpy(ld_preload_envvar, sandbox_lib, strlen(sandbox_lib));
318 strncat(ld_preload_envvar, " ", 1); 322 strncat(ld_preload_envvar, " ", 1);
319 strncat(ld_preload_envvar, getenv("LD_PRELOAD"), 323 strncat(ld_preload_envvar, getenv("LD_PRELOAD"),
320 strlen(getenv("LD_PRELOAD"))); 324 strlen(getenv("LD_PRELOAD")));
321 } else { 325 } else {
326 /* FIXME: Should probably free this at some stage - more neatness
327 * than a real leak that will cause issues. */
322 ld_preload_envvar = strndup(sandbox_lib, strlen(sandbox_lib)); 328 ld_preload_envvar = strndup(sandbox_lib, strlen(sandbox_lib));
323 if (NULL == ld_preload_envvar) 329 if (NULL == ld_preload_envvar)
324 return NULL; 330 return NULL;
325 } 331 }
326 unsetenv("LD_PRELOAD"); 332 unsetenv("LD_PRELOAD");
328 while (NULL != *env_ptr) { 334 while (NULL != *env_ptr) {
329 env_size++; 335 env_size++;
330 env_ptr++; 336 env_ptr++;
331 } 337 }
332 338
339 /* FIXME: Should probably free this at some stage - more neatness than
340 * a real leak that will cause issues. */
333 new_environ = calloc((env_size + 15 + 1) * sizeof(char *), sizeof(char *)); 341 new_environ = calloc((env_size + 15 + 1) * sizeof(char *), sizeof(char *));
334 if (NULL == new_environ) 342 if (NULL == new_environ)
335 return NULL; 343 return NULL;
336 344
337 /* First add our new variables to the beginning - this is due to some 345 /* First add our new variables to the beginning - this is due to some

Legend:
Removed from v.93  
changed lines
  Added in v.96

  ViewVC Help
Powered by ViewVC 1.1.20