/[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 287 Revision 290
128 perror("sandbox: Could not open Log file"); 128 perror("sandbox: Could not open Log file");
129 return 0; 129 return 0;
130 } 130 }
131 131
132 len = file_length(sandbox_log_file); 132 len = file_length(sandbox_log_file);
133 buffer = (char *)malloc((len + 1) * sizeof(char)); 133 buffer = (char *)xmalloc((len + 1) * sizeof(char));
134 memset(buffer, 0, len + 1); 134 memset(buffer, 0, len + 1);
135 read(sandbox_log_file, buffer, len); 135 read(sandbox_log_file, buffer, len);
136 close(sandbox_log_file); 136 close(sandbox_log_file);
137 137
138 color = ((is_env_on(ENV_NOCOLOR)) ? 0 : 1); 138 color = ((is_env_on(ENV_NOCOLOR)) ? 0 : 1);
403 tmp_env++; 403 tmp_env++;
404 404
405 /* strlen(name) + strlen(val) + '=' + '\0' */ 405 /* strlen(name) + strlen(val) + '=' + '\0' */
406 /* FIXME: Should probably free this at some stage - more neatness than 406 /* FIXME: Should probably free this at some stage - more neatness than
407 * a real leak that will cause issues. */ 407 * a real leak that will cause issues. */
408 tmp_string = calloc(strlen(name) + strlen(val) + 2, sizeof(char *)); 408 tmp_string = xcalloc(strlen(name) + strlen(val) + 2, sizeof(char *));
409 if (NULL == tmp_string) { 409 if (NULL == tmp_string) {
410 perror("sandbox: Out of memory (sandbox_setenv)"); 410 perror("sandbox: Out of memory (sandbox_setenv)");
411 exit(EXIT_FAILURE); 411 exit(EXIT_FAILURE);
412 } 412 }
413 413
447 447
448 if (NULL != getenv(ENV_LD_PRELOAD)) { 448 if (NULL != getenv(ENV_LD_PRELOAD)) {
449 have_ld_preload = 1; 449 have_ld_preload = 1;
450 orig_ld_preload_envvar = getenv(ENV_LD_PRELOAD); 450 orig_ld_preload_envvar = getenv(ENV_LD_PRELOAD);
451 451
452 ld_preload_envvar = calloc(strlen(orig_ld_preload_envvar) + 452 ld_preload_envvar = xcalloc(strlen(orig_ld_preload_envvar) +
453 strlen(sandbox_info->sandbox_lib) + 2, 453 strlen(sandbox_info->sandbox_lib) + 2,
454 sizeof(char *)); 454 sizeof(char *));
455 if (NULL == ld_preload_envvar) 455 if (NULL == ld_preload_envvar)
456 return NULL; 456 return NULL;
457 snprintf(ld_preload_envvar, strlen(orig_ld_preload_envvar) + 457 snprintf(ld_preload_envvar, strlen(orig_ld_preload_envvar) +
471 env_ptr++; 471 env_ptr++;
472 } 472 }
473 473
474 /* FIXME: Should probably free this at some stage - more neatness than 474 /* FIXME: Should probably free this at some stage - more neatness than
475 * a real leak that will cause issues. */ 475 * a real leak that will cause issues. */
476 new_environ = calloc((env_size + 15 + 1) * sizeof(char *), sizeof(char *)); 476 new_environ = xcalloc((env_size + 15 + 1) * sizeof(char *), sizeof(char *));
477 if (NULL == new_environ) 477 if (NULL == new_environ)
478 goto error; 478 goto error;
479 479
480 snprintf(sb_pid, sizeof(sb_pid), "%i", getpid()); 480 snprintf(sb_pid, sizeof(sb_pid), "%i", getpid());
481 481
640 640
641 /* If not in portage, cd into it work directory */ 641 /* If not in portage, cd into it work directory */
642 if ('\0' != sandbox_info.work_dir[0]) 642 if ('\0' != sandbox_info.work_dir[0])
643 chdir(sandbox_info.work_dir); 643 chdir(sandbox_info.work_dir);
644 644
645 argv_bash = (char **)malloc(6 * sizeof(char *)); 645 argv_bash = (char **)xmalloc(6 * sizeof(char *));
646 argv_bash[0] = strdup("/bin/bash"); 646 argv_bash[0] = strdup("/bin/bash");
647 argv_bash[1] = strdup("-rcfile"); 647 argv_bash[1] = strdup("-rcfile");
648 argv_bash[2] = strdup(sandbox_info.sandbox_rc); 648 argv_bash[2] = strdup(sandbox_info.sandbox_rc);
649 649
650 if (argc < 2) 650 if (argc < 2)
660 if (NULL == argv_bash[4]) 660 if (NULL == argv_bash[4])
661 len = 0; 661 len = 0;
662 else 662 else
663 len = strlen(argv_bash[4]); 663 len = strlen(argv_bash[4]);
664 664
665 argv_bash[4] = (char *)realloc(argv_bash[4], 665 argv_bash[4] = (char *)xrealloc(argv_bash[4],
666 (len + strlen(argv[i]) + 2) * sizeof(char)); 666 (len + strlen(argv[i]) + 2) * sizeof(char));
667 667
668 if (0 == len) 668 if (0 == len)
669 argv_bash[4][0] = 0; 669 argv_bash[4][0] = 0;
670 if (1 != i) 670 if (1 != i)

Legend:
Removed from v.287  
changed lines
  Added in v.290

  ViewVC Help
Powered by ViewVC 1.1.20