/mandos/trunk

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

« back to all changes in this revision

Viewing changes to plugins.d/mandos-client.c

  • Committer: Teddy Hogeborn
  • Date: 2018-02-18 01:03:48 UTC
  • Revision ID: teddy@recompile.se-20180218010348-hhjfox5t4py5n5zh
Client: Bug fix: Possible memory leak if failing to open /dev/null

* plugins.d/mandos-client.d (run_network_hooks): Try to open /dev/null
  before reading network hook dir in order to fail early in that case.

Show diffs side-by-side

added added

removed removed

Lines of Context:
613
613
        }
614
614
        params.size += (unsigned int)bytes_read;
615
615
      }
616
 
      ret = close(dhpfile);
617
 
      if(ret == -1){
618
 
        perror_plus("close");
619
 
      }
620
616
      if(params.data == NULL){
621
617
        dhparamsfilename = NULL;
622
618
      }
1659
1655
      perror_plus("ioctl SIOCGIFFLAGS");
1660
1656
      errno = old_errno;
1661
1657
    }
1662
 
    if((close(s) == -1) and debug){
1663
 
      old_errno = errno;
1664
 
      perror_plus("close");
1665
 
      errno = old_errno;
1666
 
    }
1667
1658
    return false;
1668
1659
  }
1669
 
  if((close(s) == -1) and debug){
1670
 
    old_errno = errno;
1671
 
    perror_plus("close");
1672
 
    errno = old_errno;
1673
 
  }
1674
1660
  return true;
1675
1661
}
1676
1662
 
3076
3062
                                                | O_PATH));
3077
3063
    if(dir_fd == -1){
3078
3064
      perror_plus("open");
3079
 
      return;
3080
3065
    }
3081
3066
    int numentries = scandirat(dir_fd, ".", &direntries,
3082
3067
                               notdotentries, alphasort);
3109
3094
      
3110
3095
      /* need to clean even if 0 because man page doesn't specify */
3111
3096
      free(direntries);
 
3097
      if(numentries == -1){
 
3098
        perror_plus("scandirat");
 
3099
      }
3112
3100
      dret = unlinkat(base, dirname, AT_REMOVEDIR);
3113
3101
      if(dret == -1 and errno != ENOENT){
3114
3102
        perror_plus("rmdir");