/mandos/release

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/release

« back to all changes in this revision

Viewing changes to plugin-runner.c

  • Committer: Björn Påhlsson
  • Date: 2008-09-05 19:30:21 UTC
  • mto: (237.7.1 mandos) (24.1.154 mandos)
  • mto: This revision was merged to the branch mainline in revision 176.
  • Revision ID: belorn@braxen-20080905193021-vie7b22ootg6r2t8
Several memory leaks detected by valgrind fixed
A bugg fixed that could cause seg fault.

Show diffs side-by-side

added added

removed removed

Lines of Context:
255
255
/* Prints out a password to stdout */
256
256
bool print_out_password(const char *buffer, size_t length){
257
257
  ssize_t ret;
 
258
  if(length>0 and buffer[length-1] == '\n'){
 
259
    length--;
 
260
  }
258
261
  for(size_t written = 0; written < length; written += (size_t)ret){
259
262
    ret = TEMP_FAILURE_RETRY(write(STDOUT_FILENO, buffer + written,
260
263
                                   length - written));
473
476
      debug = true;
474
477
      break;
475
478
    case ARGP_KEY_ARG:
476
 
      /* Cryptsetup always passes an argument, which is an empty
477
 
         string if "none" was specified in /etc/crypttab.  So if
478
 
         argument was empty, we ignore it silently. */
479
 
      if(arg[0] != '\0'){
480
 
        fprintf(stderr, "Ignoring unknown argument \"%s\"\n", arg);
481
 
      }
 
479
      fprintf(stderr, "Ignoring unknown argument \"%s\"\n", arg);
482
480
      break;
483
481
    case ARGP_KEY_END:
484
482
      break;
739
737
    }
740
738
 
741
739
    char *filename;
742
 
    if(plugindir == NULL){
743
 
      ret = asprintf(&filename, PDIR "/%s", dirst->d_name);
744
 
    } else {
745
 
      ret = asprintf(&filename, "%s/%s", plugindir, dirst->d_name);
746
 
    }
 
740
    ret = asprintf(&filename, "%s/%s", plugindir, dirst->d_name);
747
741
    if(ret < 0){
748
742
      perror("asprintf");
749
743
      continue;
1045
1039
    bool bret;
1046
1040
    fprintf(stderr, "Going to fallback mode using getpass(3)\n");
1047
1041
    char *passwordbuffer = getpass("Password: ");
1048
 
    size_t len = strlen(passwordbuffer);
1049
 
    /* Strip trailing newline */
1050
 
    if(len > 0 and passwordbuffer[len-1] == '\n'){
1051
 
      passwordbuffer[len-1] = '\0'; /* not strictly necessary */
1052
 
      len--;
1053
 
    }
1054
 
    bret = print_out_password(passwordbuffer, len);
 
1042
    bret = print_out_password(passwordbuffer, strlen(passwordbuffer));
1055
1043
    if(not bret){
1056
1044
      perror("print_out_password");
1057
1045
      exitstatus = EXIT_FAILURE;