/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 plugins.d/splashy.c

  • Committer: Teddy Hogeborn
  • Date: 2008-09-23 20:32:01 UTC
  • Revision ID: teddy@fukt.bsnet.se-20080923203201-3206nf092qsy7rvk
* plugins.d/splashy.c (main): Bug fix: free "exe_link".

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
  interrupted_by_signal = 1;
26
26
}
27
27
 
28
 
int main(__attribute__((unused))int argc,
29
 
         __attribute__((unused))char **argv){
 
28
int main(__attribute__((unused))int argc, char **argv){
30
29
  int ret = 0;
31
30
  
32
31
  /* Create prompt string */
77
76
      }
78
77
      /* Find the executable name by doing readlink() on the
79
78
         /proc/<pid>/exe link */
 
79
      char *exe_link;
 
80
      ret = asprintf(&exe_link, "/proc/%s/exe", proc_ent->d_name);
 
81
      if(ret == -1){
 
82
        perror("asprintf");
 
83
        free(prompt);
 
84
        closedir(proc_dir);
 
85
        return EXIT_FAILURE;
 
86
      }
80
87
      char exe_target[sizeof(splashy_name)];
81
 
      ssize_t sret;
82
 
      {
83
 
        char *exe_link;
84
 
        ret = asprintf(&exe_link, "/proc/%s/exe", proc_ent->d_name);
85
 
        if(ret == -1){
86
 
          perror("asprintf");
87
 
          free(prompt);
88
 
          closedir(proc_dir);
89
 
          return EXIT_FAILURE;
90
 
        }
91
 
        sret = readlink(exe_link, exe_target, sizeof(exe_target));
92
 
        free(exe_link);
93
 
      }
 
88
      ssize_t sret = readlink(exe_link, exe_target,
 
89
                              sizeof(exe_target));
 
90
      free(exe_link);
94
91
      if((sret == ((ssize_t)sizeof(exe_target)-1))
95
92
         and (memcmp(splashy_name, exe_target,
96
93
                     sizeof(exe_target)-1) == 0)){