Changeset 170 for trunk/src/samhain.c
- Timestamp:
- Apr 30, 2008, 11:56:45 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/samhain.c
r169 r170 167 167 } 168 168 169 void sh_g_init( )169 void sh_g_init(void) 170 170 { 171 171 if (0 != pthread_key_create(&g_key, sh_g_destroy)) … … 695 695 #endif 696 696 #if defined(SH_WITH_SERVER) 697 extern int sh_socket_remove ( );697 extern int sh_socket_remove (void); 698 698 #endif 699 699 … … 800 800 #if defined(__linux__) || defined(sun) || defined(__sun) || defined(__sun__) 801 801 #include <dirent.h> 802 static pid_t * procdirSamhain ( )802 static pid_t * procdirSamhain (void) 803 803 { 804 volatile pid_t * pidlist = malloc(sizeof(pid_t) * 65535); 805 pid_t * dummy; 804 pid_t * pidlist; 806 805 struct dirent * d; 807 806 DIR * dp; 808 807 long ino; 809 808 struct stat buf; 810 int i = 0;809 int i; 811 810 pid_t pid, mypid = getpid(); 812 811 char * tail; 813 812 char exef[128]; 814 813 815 if (!pidlist)816 return NULL;817 818 for (i = 0; i < 65535; ++i) pidlist[i] = 0;819 i = 0;820 821 814 if (0 != stat(SH_INSTALL_PATH, &buf)) 822 815 { 823 dummy = (pid_t *)pidlist;824 free(dummy);825 816 return NULL; 826 817 } … … 830 821 if (NULL == (dp = opendir("/proc"))) 831 822 { 832 dummy = (pid_t *)pidlist;833 free(dummy);834 823 return NULL; 835 824 } … … 837 826 SH_MUTEX_LOCK(mutex_readdir); 838 827 828 pidlist = malloc(sizeof(pid_t) * 65535); 829 if (!pidlist) 830 goto unlock_and_out; 831 832 for (i = 0; i < 65535; ++i) pidlist[i] = 0; 833 834 i = 0; 839 835 while (NULL != (d = readdir(dp)) && i < 65535) 840 836 { … … 858 854 } 859 855 856 unlock_and_out: 857 ; 860 858 SH_MUTEX_UNLOCK(mutex_readdir); 861 859 862 860 closedir(dp); 863 return (pid_t *)pidlist;861 return pidlist; 864 862 } 865 863 #else 866 static pid_t * procdirSamhain ( )864 static pid_t * procdirSamhain (void) 867 865 { 868 866 return NULL; … … 1191 1189 #endif 1192 1190 #if defined(SH_WITH_SERVER) 1193 extern int sh_create_tcp_socket( );1191 extern int sh_create_tcp_socket(void); 1194 1192 #endif 1195 1193 … … 1208 1206 1209 1207 volatile time_t told; 1210 time_t tcurrent;1208 volatile time_t tcurrent; 1211 1209 size_t tzlen; 1212 1210 char * tzptr;
Note:
See TracChangeset
for help on using the changeset viewer.