- Timestamp:
- Oct 28, 2007, 1:17:58 AM (17 years ago)
- Location:
- trunk/src
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/CuTest.c
r96 r137 32 32 #include <string.h> 33 33 #include <math.h> 34 #include <unistd.h> 34 35 35 36 #include "CuTest.h" -
trunk/src/cutest_sh_tiger0.c
r133 r137 9 9 #include "sh_tiger.h" 10 10 11 #if defined(HAVE_PTHREAD) && defined(SH_STEALTH) 12 extern void sh_g_init(); 13 #endif 14 15 11 16 static void init() { 12 17 … … 16 21 int i; 17 22 23 #if defined(HAVE_PTHREAD) && defined(SH_STEALTH) 24 sh_g_init(); 25 #endif 18 26 skey = (sh_key_t *) malloc (sizeof(sh_key_t)); 19 27 if (skey != NULL) … … 69 77 char hashbuf[KEYBUF_SIZE]; 70 78 79 #if defined(HAVE_PTHREAD) && defined(SH_STEALTH) 80 sh_g_init(); 81 #endif 82 71 83 input = ""; 72 84 actual = sh_tiger_hash(input, TIGER_DATA, strlen(input), hashbuf, sizeof(hashbuf)); -
trunk/src/samhain.c
r134 r137 139 139 140 140 #ifdef HAVE_PTHREAD 141 typedefstruct gt {141 struct gt { 142 142 size_t g_count; 143 143 char * g_glob; … … 149 149 { 150 150 struct gt * ptr = malloc(sizeof(struct gt)); 151 if (! gt)151 if (!ptr) 152 152 return -1; 153 153 ptr->g_count = 0; … … 166 166 } 167 167 168 staticvoid sh_g_init()168 void sh_g_init() 169 169 { 170 170 if (0 != pthread_key_create(&g_key, sh_g_destroy)) … … 176 176 if (0 != sh_g_thread()) 177 177 { 178 perror(" 1");178 perror("2"); 179 179 exit(EXIT_FAILURE); 180 180 } … … 191 191 size_t j; 192 192 193 #ifdef HAVE_PTHREAD 194 struct gt * ptr = pthread_getspecific(g_key); 195 size_t count = ptr->g_count; 196 char * glob = ptr->g_glob; 197 #else 193 #ifndef HAVE_PTHREAD 198 194 static size_t count = 0; 199 195 static char glob[SH_MAX_GLOBS * (GLOB_LEN+1)]; 200 # 201 202 if (str == NULL) 196 #else 197 struct gt * ptr = pthread_getspecific(g_key); 198 size_t count; 199 char * glob; 200 201 if (ptr) { 202 count = ptr->g_count; 203 glob = ptr->g_glob; 204 } else { 203 205 return NULL; 206 } 207 #endif 208 209 if (str != NULL) 210 j = strlen(str); 204 211 else 205 j = strlen(str);212 return NULL; 206 213 207 214 ASSERT((j <= GLOB_LEN), _("j <= GLOB_LEN")) … … 228 235 i = count; 229 236 #ifdef HAVE_PTHREAD 230 ptr-> count = count + j + 1;237 ptr->g_count = count + j + 1; 231 238 #else 232 239 count = count + j + 1; … … 248 255 } 249 256 257 #else 258 /* not stealth */ 259 #define SH_G_INIT ((void)0) 250 260 #endif 251 261 … … 815 825 } 816 826 817 SH_MUTEX_LOCK( readdir_lock);827 SH_MUTEX_LOCK(mutex_readdir); 818 828 819 829 while (NULL != (d = readdir(dp)) && i < 65535) … … 838 848 } 839 849 840 SH_MUTEX_UNLOCK( readdir_lock);850 SH_MUTEX_UNLOCK(mutex_readdir); 841 851 842 852 closedir(dp); -
trunk/src/sh_calls.c
r134 r137 781 781 if (i < 0) 782 782 sh_error_handle ((-1), file, line, error, MSG_ERR_PIPE, 783 sh_error_message(error ),783 sh_error_message(error, errbuf, sizeof(errbuf)), 784 784 (long) 0, (long) 0); 785 785 else -
trunk/src/sh_err_console.c
r132 r137 70 70 key_t key; 71 71 int error; 72 #if defined(WITH_TPT) 72 73 char errbuf[SH_ERRBUF_SIZE]; 74 #endif 73 75 74 76 SL_ENTER(_("open_ipc")); … … 132 134 int error; 133 135 int count = 0; 136 #if defined(WITH_TPT) 134 137 char errbuf[SH_ERRBUF_SIZE]; 138 #endif 135 139 136 140 SL_ENTER(_("push_message_queue")); -
trunk/src/sh_err_log.c
r133 r137 649 649 char * sigkey_old; 650 650 char * crypto; 651 char hashbuf[KEYBUF_SIZE]; 651 652 652 653 SL_ENTER(_("sh_log_file")); … … 865 866 if (current->log_start == S_TRUE) 866 867 { 867 char hashbuf[KEYBUF_SIZE];868 869 868 if (sh.real.user[0] == '\0') 870 869 (void) sh_unix_getUser(); … … 948 947 log_msg.timestamp[0] = '\0'; 949 948 (void) sl_strlcpy (sigkey_new, 950 sh_tiger_hash (sigkey_old, TIGER_DATA, KEY_LEN ),949 sh_tiger_hash (sigkey_old, TIGER_DATA, KEY_LEN, hashbuf, sizeof(hashbuf)), 951 950 KEY_LEN+1); 952 951 } … … 954 953 /* --- Sign the message with the signature key. --- 955 954 */ 955 sh_tiger_hash (log_msg.msg, -1, 10, hashbuf, 10); 956 sh_tiger_hash (log_msg.msg, TIGER_DATA, 957 (unsigned long)(status + KEY_LEN), (char *) hashbuf, (size_t) sizeof(hashbuf)); 956 958 957 959 (void) sl_strlcat (log_msg.msg, sigkey_new, (size_t)(status + KEY_LEN + 2)); 958 959 960 (void) sl_strlcpy (log_msg.signature, 960 sh_tiger_hash (log_msg.msg, TIGER_DATA,961 (unsigned long)(status + KEY_LEN) ),961 sh_tiger_hash (log_msg.msg, (TigerType) TIGER_DATA, 962 (unsigned long)(status + KEY_LEN), hashbuf, sizeof(hashbuf)), 962 963 KEY_LEN+1); 963 964 (void) sl_strlcpy (sigkey_old, sigkey_new, KEY_LEN+1); -
trunk/src/sh_files.c
r132 r137 51 51 #endif 52 52 #endif 53 #define NEED_ADD_DIRENT 53 54 54 55 #ifdef HAVE_GLOB_H … … 1636 1637 /* ---- read ---- 1637 1638 */ 1638 SH_MUTEX_LOCK( readdir_lock);1639 SH_MUTEX_LOCK(mutex_readdir); 1639 1640 1640 1641 do { … … 1657 1658 } while (thisEntry != NULL); 1658 1659 1659 SH_MUTEX_UNLOCK( readdir_lock);1660 SH_MUTEX_UNLOCK(mutex_readdir); 1660 1661 1661 1662 closedir (thisDir); -
trunk/src/sh_forward.c
r133 r137 277 277 register int i; 278 278 unsigned char * dez = NULL; 279 char hashbuf[KEYBUF_SIZE]; 279 280 280 281 if (password == NULL) … … 297 298 } 298 299 (void) sl_strlcpy (skey->vernam, 299 sh_tiger_hash(skey->vernam, TIGER_DATA, PW_LEN), 300 sh_tiger_hash(skey->vernam, TIGER_DATA, PW_LEN, 301 hashbuf, sizeof(hashbuf)), 300 302 KEY_LEN+1); 301 303 } … … 320 322 (void) sl_strlcpy (hash, 321 323 sh_tiger_hash(combi, TIGER_DATA, 322 (unsigned long) sl_strlen(combi)), 324 (unsigned long) sl_strlen(combi), 325 hashbuf, sizeof(hashbuf)), 323 326 KEY_LEN+1); 324 327 … … 1012 1015 /* --- Create own nonce. --- 1013 1016 */ 1014 ticks = (UINT32) taus_get (&(skey->rng0[0]), 1015 &(skey->rng1[0]), 1016 &(skey->rng2[0])); 1017 ticks = (UINT32) taus_get (); 1018 1017 1019 (void) sl_strlcpy(nonce_u, 1018 1020 sh_tiger_hash((char *) &ticks, … … 1591 1593 /* --- Generate a nonce. --- 1592 1594 */ 1593 ticks = (UINT32) taus_get (&(skey->rng0[0]), 1594 &(skey->rng1[0]), 1595 &(skey->rng2[0])); 1595 ticks = (UINT32) taus_get (); 1596 1596 1597 1597 (void) sl_strlcpy(nclt, … … 1897 1897 char hashbuf[KEYBUF_SIZE]; 1898 1898 1899 val[0] = taus_get ( &(skey->rng0[0]), &(skey->rng0[1]), &(skey->rng0[2]));1900 val[1] = taus_get ( &(skey->rng0[0]), &(skey->rng0[1]), &(skey->rng0[2]));1899 val[0] = taus_get (); 1900 val[1] = taus_get (); 1901 1901 1902 1902 sl_strlcpy (output, … … 2970 2970 sl_strlcpy (conn->peer, &(conn->buf[KEY_LEN]), SH_MINIBUF+1); 2971 2971 2972 ticks = (UINT32) taus_get (&(skey->rng0[0]), 2973 &(skey->rng1[0]), 2974 &(skey->rng2[0])); 2972 ticks = (UINT32) taus_get (); 2973 2975 2974 if (conn->K != NULL) 2976 2975 { … … 3430 3429 sl_strlcpy (conn->peer, &(conn->buf[KEY_LEN]), SH_MINIBUF+1); 3431 3430 3432 ticks = (UINT32) taus_get (&(skey->rng0[0]), 3433 &(skey->rng1[0]), 3434 &(skey->rng2[0])); 3431 ticks = (UINT32) taus_get (); 3432 3435 3433 test = (char *) &ticks; 3436 3434 sh_util_cpylong (conn->challenge, test, 4); … … 3790 3788 /* -- create server nounce v -- 3791 3789 */ 3792 ticks = (UINT32) taus_get (&(skey->rng0[0]), 3793 &(skey->rng1[0]), 3794 &(skey->rng2[0])); 3790 ticks = (UINT32) taus_get (); 3795 3791 3796 3792 if (conn->A != NULL) … … 4116 4112 * create nonce u 4117 4113 */ 4118 ticks = (UINT32) taus_get (&(skey->rng0[0]), 4119 &(skey->rng1[0]), 4120 &(skey->rng2[0])); 4114 ticks = (UINT32) taus_get (); 4115 4121 4116 test = (char *) &ticks; 4122 4117 sh_util_cpylong (u, test, 4); /* u nounce */ -
trunk/src/sh_gpg.c
r133 r137 554 554 * between the integrity check and the execve 555 555 */ 556 myrand = (int) taus_get ( &(skey->rng0[0]), &(skey->rng1[0]),557 &(skey->rng2[0])); 556 myrand = (int) taus_get (); 557 558 558 myrand = (myrand < 0) ? (-myrand) : myrand; 559 559 myrand = (myrand % 32) + 2; -
trunk/src/sh_hash.c
r133 r137 2010 2010 int i = 0; 2011 2011 char * p; 2012 char i2h[2]; 2012 2013 2013 2014 tmpFile.attr_string = NULL; … … 2035 2036 for (i = 0; i < size; ++i) 2036 2037 { 2037 p = sh_util_charhex (str[i] );2038 p = sh_util_charhex (str[i],i2h); 2038 2039 tmpFile.linkpath[2*i] = p[0]; 2039 2040 tmpFile.linkpath[2*i+1] = p[1]; -
trunk/src/sh_kern.c
r132 r137 202 202 char *linkpath_old; 203 203 char *linkpath_new; 204 char i2h[2]; 204 205 205 206 #ifdef SH_USE_XML … … 226 227 for (k = 0; k < old_len; ++k) 227 228 { 228 p = sh_util_charhex (old[k] );229 p = sh_util_charhex (old[k], i2h); 229 230 linkpath_old[2*k] = p[0]; 230 231 linkpath_old[2*k+1] = p[1]; … … 234 235 for (k = 0; k < new_len; ++k) 235 236 { 236 p = sh_util_charhex (new[k] );237 p = sh_util_charhex (new[k], i2h); 237 238 linkpath_new[2*k] = p[0]; 238 239 linkpath_new[2*k+1] = p[1]; … … 967 968 if (df) 968 969 { 969 SH_MUTEX_LOCK( readdir_lock);970 SH_MUTEX_LOCK(mutex_readdir); 970 971 971 972 while (NULL != (entry = readdir(df))) … … 981 982 } 982 983 983 SH_MUTEX_UNLOCK( readdir_lock);984 SH_MUTEX_UNLOCK(mutex_readdir); 984 985 985 986 closedir(df); -
trunk/src/sh_mail.c
r134 r137 58 58 #include "sh_fifo.h" 59 59 #include "sh_tools.h" 60 #include "sh_pthread.h" 60 61 61 62 #undef FIL__ … … 1246 1247 #endif 1247 1248 1248 static int sh_mail_wait(int code, FILE * m_socket);1249 static int sh_mail_wait(int code, int ma_socket); 1249 1250 1250 1251 static char * relay_host = NULL; … … 1680 1681 g = (int) c; 1681 1682 1682 if ( (g=fgetc(ma_socket)) == EOF) 1683 /* 1684 if (g == EOF) 1683 1685 { 1684 1686 TPT((0, FIL__, __LINE__, _("msg=<mail_wait: EOF>\n"))); 1685 1687 SL_RETURN( 0, _("mail_wait")); 1686 1688 } 1689 */ 1687 1690 1688 1691 switch(state) { … … 2101 2104 dnsrep * answers = NULL; 2102 2105 mx * result; 2103 dnsrep * retval ;2106 dnsrep * retval = NULL; 2104 2107 char errmsg[128]; 2105 2108 size_t len; -
trunk/src/sh_mem.c
r134 r137 20 20 #include "config_xor.h" 21 21 22 /* With glibc, _XOPEN_SOURCE 500 is required for 23 * pthread_mutexattr_settype/PTHREAD_MUTEX_RECURSIVE 24 */ 25 #if defined(HAVE_PTHREAD) && defined(MEM_DEBUG) 26 #define _XOPEN_SOURCE 500 27 #endif 22 28 23 29 #include <stdio.h> … … 108 114 static pthread_mutex_t mutex_mem; 109 115 110 static intinitialize_mem(void)116 static void initialize_mem(void) 111 117 { 112 118 pthread_mutexattr_t mta; … … 114 120 pthread_mutex_init(&mutex_mem, &mta); 115 121 pthread_mutexattr_destroy(&mta); 116 return 0;122 return; 117 123 } 118 124 #define MEM_MUTEX_INIT (void) pthread_once(&mem_is_initialized, initialize_mem) -
trunk/src/sh_portcheck.c
r134 r137 115 115 #include "sh_utils.h" 116 116 #include "sh_modules.h" 117 #include "sh_pthread.h" 117 118 118 119 static int sh_portchk_severity = SH_ERR_SEVERE; -
trunk/src/sh_srp.c
r133 r137 341 341 342 342 for (i = 0; i < 6; ++i) 343 randl[i] = (UINT32) taus_get (&(skey->rng0[0]), 344 &(skey->rng1[0]), 345 &(skey->rng2[0])); 343 randl[i] = (UINT32) taus_get (); 344 346 345 (void) sl_strlcpy (hash, 347 346 sh_tiger_hash((char *)&randl[0], TIGER_DATA, -
trunk/src/sh_suidchk.c
r132 r137 69 69 #endif 70 70 #endif 71 #define NEED_ADD_DIRENT 71 72 72 73 #include "samhain.h" … … 869 870 /* Loop over directory entries 870 871 */ 871 SH_MUTEX_LOCK( readdir_lock);872 SH_MUTEX_LOCK(mutex_readdir); 872 873 873 874 do { … … 892 893 } while (thisEntry != NULL); 893 894 894 SH_MUTEX_UNLOCK( readdir_lock);895 SH_MUTEX_UNLOCK(mutex_readdir); 895 896 896 897 closedir(thisDir); … … 1080 1081 if (-1 == fflags) 1081 1082 { 1082 (void) sh_unix_gmttime (theFile ->ctime, timestrc, sizeof(timestrc));1083 (void) sh_unix_gmttime (theFile ->atime, timestra, sizeof(timestra));1084 (void) sh_unix_gmttime (theFile ->mtime, timestrm, sizeof(timestrm));1083 (void) sh_unix_gmttime (theFile.ctime, timestrc, sizeof(timestrc)); 1084 (void) sh_unix_gmttime (theFile.atime, timestra, sizeof(timestra)); 1085 (void) sh_unix_gmttime (theFile.mtime, timestrm, sizeof(timestrm)); 1085 1086 1086 1087 report_file(tmpcat, &theFile, timestrc, timestra, timestrm); -
trunk/src/sh_tiger0.c
r134 r137 24 24 #include "sh_error.h" 25 25 #include "sh_utils.h" 26 #include "sh_pthread.h" 26 27 27 28 #define PRIV_MAX 32768 … … 121 122 UINT64 bcount = 0; 122 123 123 char* buffer = SH_ALLOC(PRIV_MAX + 72);124 sh_byte * buffer = SH_ALLOC(PRIV_MAX + 72); 124 125 125 126 unsigned long pages_read; … … 156 157 if (what >= TIGER_FILE) 157 158 { 158 if (what > TIGER_F D)159 if (what > TIGER_FILE) 159 160 { 160 161 fd = what; … … 829 830 size_t sum; 830 831 831 SL_TICKET fd;832 832 char * tmp; 833 833 uid_t euid; … … 869 869 870 870 n = (off_t) sl_read_timeout (fd, buffer + sum, 871 (size_t) BLOCKSIZE - sum, timeout );871 (size_t) BLOCKSIZE - sum, timeout, SL_FALSE); 872 872 873 873 if (SL_ISERROR (n)) … … 1339 1339 char buffer[4168]; /* BLOCKSIZE + 72 AIX compiler chokes */ 1340 1340 off_t sum = 0; 1341 SL_TICKET fd;1342 1341 char * tmp; 1343 1342 uid_t euid; … … 1379 1378 do { 1380 1379 n = (off_t) sl_read_timeout(fd, buffer + sum, 1381 (size_t) BLOCKSIZE - sum, timeout );1380 (size_t) BLOCKSIZE - sum, timeout, SL_FALSE); 1382 1381 1383 1382 if (SL_ISERROR (n)) -
trunk/src/sh_tools.c
r134 r137 88 88 #define SH_NEED_GETHOSTBYXXX 89 89 #include "sh_static.h" 90 #include "sh_pthread.h" 90 91 91 92 #undef FIL__ … … 723 724 struct sigaction new_act; 724 725 struct sigaction old_act; 726 #if defined(WITH_TPT) 725 727 char errbuf[SH_ERRBUF_SIZE]; 728 #endif 726 729 727 730 SL_ENTER(_("sh_write_select")); … … 1144 1147 /* random_pad 1145 1148 */ 1146 rpad[1] = taus_get ( &(skey->rng0[0]), &(skey->rng1[0]), &(skey->rng2[0]));1149 rpad[1] = taus_get (); 1147 1150 memcpy (head, &rpad[1], 4); 1148 rpad[0] = taus_get ( &(skey->rng0[0]), &(skey->rng1[0]), &(skey->rng2[0]));1151 rpad[0] = taus_get (); 1149 1152 memcpy (&head[4], &rpad[0], 4); 1150 rpad[2] = taus_get ( &(skey->rng0[0]), &(skey->rng1[0]), &(skey->rng2[0]));1153 rpad[2] = taus_get (); 1151 1154 memcpy (&head[8], &rpad[2], 4); 1152 1155 … … 1634 1637 /* create random filename in effective users home directory 1635 1638 */ 1636 ticks = taus_get ( &(skey->rng0[0]), &(skey->rng1[0]), &(skey->rng2[0]));1639 ticks = taus_get (); 1637 1640 if (my_tmp_dir[0] == '/' && my_tmp_dir[1] == '\0') 1638 1641 file = sh_util_strconcat (my_tmp_dir, -
trunk/src/sh_unix.c
r134 r137 94 94 #include "sh_tiger.h" 95 95 #include "sh_prelink.h" 96 #include "sh_pthread.h" 96 97 97 98 /* moved here from far below … … 956 957 static int tf_add_trusted_user_int(const char * c) 957 958 { 958 registerstruct passwd * w;959 struct passwd * w; 959 960 int count; 960 961 uid_t pwid = (uid_t)-1; … … 970 971 */ 971 972 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 972 s tatus = sh_getpwnam_r(c, &pwd, buffer, sizeof(buffer), &w);973 sh_getpwnam_r(c, &pwd, buffer, sizeof(buffer), &w); 973 974 #else 974 975 w = sh_getpwnam(c); … … 3243 3244 ShFileType type; 3244 3245 unsigned int mode; 3245 char * name;3246 3246 char * tmp; 3247 3247 char * tmp2; … … 3545 3545 3546 3546 3547 if (NULL == sh_unix_getUIDname(SH_ERR_ALL, buf.st_uid, theFile->c_owner, USER_MAX+ )) {3547 if (NULL == sh_unix_getUIDname(SH_ERR_ALL, buf.st_uid, theFile->c_owner, USER_MAX+1)) { 3548 3548 3549 3549 tmp2 = sh_util_safe_name (theFile->fullpath); … … 3571 3571 tmp2 = sh_util_safe_name ((filename == NULL) ? 3572 3572 theFile->fullpath : filename); 3573 (void) sh_unix_time(theFile->mtime, timestr, sizeof(timestr ing));3573 (void) sh_unix_time(theFile->mtime, timestr, sizeof(timestr)); 3574 3574 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_FI_LIST, 3575 3575 theFile->c_mode, -
trunk/src/sh_userfiles.c
r134 r137 30 30 #include <pwd.h> 31 31 32 33 32 #include "samhain.h" 34 33 #include "sh_modules.h" … … 41 40 #define SH_NEED_PWD_GRP 1 42 41 #include "sh_static.h" 42 #include "sh_pthread.h" 43 43 44 44 #ifdef SH_USE_USERFILES -
trunk/src/sh_utils.c
r133 r137 45 45 #include "sh_tiger.h" 46 46 #include "sh_entropy.h" 47 #include "sh_pthread.h" 47 48 48 49 #undef FIL__ … … 570 571 } 571 572 572 char * sh_util_charhex( unsigned char i ) 573 { 574 static char i2h[2]; 573 char * sh_util_charhex( unsigned char i , char * i2h) 574 { 575 575 int j, k; 576 576 … … 669 669 UINT32 * h2; 670 670 UINT32 cc[KEY_LEN/4]; 671 char * res;672 671 UINT32 kbuf[KEY_BYT/sizeof(UINT32)]; 673 672 char hashbuf[KEYBUF_SIZE]; … … 681 680 if (KEY_BLOCK > (KEY_LEN/2)) 682 681 { 683 res = sh_tiger_hash (NULL, TIGER_DATA, 0, hashbuf, sizeof(hashbuf)); 682 (void) sh_tiger_hash (NULL, TIGER_DATA, 0, hashbuf, sizeof(hashbuf)); 683 sl_strlcpy(res, hashbuf, len); 684 684 SL_RETURN(res, _("sh_util_hmac_tiger")); 685 685 } … … 689 689 if (sh_util_hextobinary (K, hexkey, KEY_LEN) < 0) 690 690 { 691 res = sh_tiger_hash (NULL, TIGER_DATA, 0, hashbuf, sizeof(hashbuf)); 691 (void) sh_tiger_hash (NULL, TIGER_DATA, 0, hashbuf, sizeof(hashbuf)); 692 sl_strlcpy(res, hashbuf, len); 692 693 SL_RETURN(res, _("sh_util_hmac_tiger")); 693 694 } … … 712 713 _("integer overflow"), 713 714 _("sh_util_hmac_tiger")); 714 res = sh_tiger_hash (NULL, TIGER_DATA, 0, hashbuf, sizeof(hashbuf)); 715 (void) sh_tiger_hash (NULL, TIGER_DATA, 0, hashbuf, sizeof(hashbuf)); 716 sl_strlcpy(res, hashbuf, len); 715 717 SL_RETURN(res, _("sh_util_hmac_tiger")); 716 718 } … … 749 751 750 752 static char * sh_util_hash_tiger ( char * hexkey, 751 char * text, size_t textlen 753 char * text, size_t textlen, 752 754 char * res, size_t len) 753 755 { 754 756 char h2[2*KEY_LEN+1]; 757 char hashbuf[KEYBUF_SIZE]; 758 755 759 SL_ENTER(_("sh_util_hash_tiger")); 756 760 … … 760 764 (unsigned long) textlen, 761 765 hashbuf, sizeof(hashbuf)), 762 2*KEY_LEN+1 ,766 2*KEY_LEN+1 763 767 ); 764 768 … … 917 921 UINT32 * state = (UINT32 *) vstate; 918 922 923 /* 919 924 if (skey->rngI == BAD) 920 925 (void)taus_seed(); 926 */ 921 927 922 928 #define TAUSWORTHE(s,a,b,c,d) ((s &c) <<d) ^ (((s <<a) ^s) >>b) … … 932 938 * input for a one-way hash function. 933 939 */ 934 UINT32 taus_svec[6]; 935 936 UINT32 taus_get (void *state1, void *state2, void *state3) 937 { 940 941 UINT32 taus_get () 942 { 943 UINT32 taus_svec[6]; 938 944 UINT32 retval; 939 945 UINT32 * res; … … 943 949 UINT32 kbuf[KEY_BYT/sizeof(UINT32)]; 944 950 951 SH_MUTEX_LOCK_UNSAFE(mutex_skey); 945 952 if (res_num > 0) 946 953 { 947 954 retval = res_vec[res_num]; 948 955 res_num = (res_num == 5) ? 0 : (res_num + 1); 956 SH_MUTEX_UNLOCK_UNSAFE(mutex_skey); /* alternative path */ 949 957 return retval; 950 958 } 951 952 taus_svec[0] = taus_get_long (state1); 953 taus_svec[1] = taus_get_long (state2); 954 taus_svec[2] = taus_get_long (state3); 955 taus_svec[3] = taus_get_long (state1); 956 taus_svec[4] = taus_get_long (state2); 957 taus_svec[5] = taus_get_long (state3); 959 SH_MUTEX_UNLOCK_UNSAFE(mutex_skey); 960 961 (void)taus_seed(); 962 963 SH_MUTEX_LOCK_UNSAFE(mutex_skey); 964 taus_svec[0] = taus_get_long (&(skey->rng0[0])); 965 taus_svec[1] = taus_get_long (&(skey->rng1[0])); 966 taus_svec[2] = taus_get_long (&(skey->rng2[2])); 967 taus_svec[3] = taus_get_long (&(skey->rng0[0])); 968 taus_svec[4] = taus_get_long (&(skey->rng1[0])); 969 taus_svec[5] = taus_get_long (&(skey->rng2[0])); 970 SH_MUTEX_UNLOCK_UNSAFE(mutex_skey); 958 971 959 972 res = sh_tiger_hash_uint32 ( (char *) &taus_svec[0], … … 962 975 kbuf, KEY_BYT/sizeof(UINT32)); 963 976 977 SH_MUTEX_LOCK_UNSAFE(mutex_skey); 964 978 for (i = 1; i < 6; ++i) 965 979 { … … 968 982 retval = taus_svec[0]; 969 983 res_num = 1; 984 SH_MUTEX_UNLOCK_UNSAFE(mutex_skey); 970 985 971 986 taus_svec[0] = 0; taus_svec[1] = 0; taus_svec[2] = 0; … … 1027 1042 int status; 1028 1043 static unsigned long seed_time = 0; 1044 unsigned long gtime; 1029 1045 1030 1046 SL_ENTER(_("taus_seed")); … … 1032 1048 if (skey->rngI == GOOD) 1033 1049 { 1034 if ( (sh_unix_longtime () - seed_time) < 3600)1050 if ( (sh_unix_longtime () - seed_time) < 7200) 1035 1051 SL_RETURN( (0), _("taus_seed")); 1036 1052 } … … 1042 1058 if (!SL_ISERROR(status)) 1043 1059 { 1044 skey->rngI = GOOD;1060 SH_MUTEX_LOCK_UNSAFE(mutex_skey); 1045 1061 memcpy (&skey->rng0[0], &bufx[0], 2*sizeof(UINT32)); 1046 1062 memcpy (&skey->rng1[0], &bufx[2*sizeof(UINT32)], 2*sizeof(UINT32)); … … 1056 1072 taus_set_from_state( &(skey->rng2[0]), &(skey->rng2[0])); 1057 1073 1074 skey->rngI = GOOD; 1075 SH_MUTEX_UNLOCK_UNSAFE(mutex_skey); 1058 1076 SL_RETURN( (0), _("taus_seed")); 1059 1077 } … … 1064 1082 /* emergency backup - unsafe ! 1065 1083 */ 1066 skey->rngI = GOOD;1067 1084 #ifdef HAVE_GETTIMEOFDAY 1068 taus_set_from_ulong ( &(skey->rng0[0]), LCG (sh_unix_notime()));1085 gtime = sh_unix_notime(); 1069 1086 #else 1070 taus_set_from_ulong ( &(skey->rng0[0]), LCG (seed_time) );1087 gtime = seed_time; 1071 1088 #endif 1089 1090 SH_MUTEX_LOCK_UNSAFE(mutex_skey); 1091 taus_set_from_ulong ( &(skey->rng0[0]), LCG (gtime) ); 1072 1092 taus_set_from_ulong ( &(skey->rng1[0]), LCG (skey->rng0[0]) ); 1073 1093 taus_set_from_ulong ( &(skey->rng2[0]), LCG (skey->rng1[0]) ); 1074 1094 skey->rngI = BAD; 1095 SH_MUTEX_UNLOCK_UNSAFE(mutex_skey); 1075 1096 1076 1097 SL_RETURN( (-1), _("taus_seed")); -
trunk/src/slib.c
r131 r137 1466 1466 int sl_policy_get_user(char * user) 1467 1467 { 1468 struct passwd * tempres;1469 1470 1468 SL_ENTER(_("sl_policy_get_user")); 1471 1469 … … 2126 2124 int timeout, int is_nonblocking) 2127 2125 { 2128 int sflags ;2126 int sflags = 0; 2129 2127 fd_set readfds; 2130 2128 struct timeval tv; … … 2132 2130 int retval; 2133 2131 2134 int fd;2135 2132 int byteread = 0; 2136 2133 int bytes = 0; -
trunk/src/trustfile.c
r134 r137 103 103 #define SH_NEED_PWD_GRP 1 104 104 #include "sh_static.h" 105 #define SH_GRBUF_SIZE 4096 106 #define SH_PWBUF_SIZE 4096 105 #include "sh_pthread.h" 107 106 108 107 #else … … 411 410 int isingrp(gid_t grp, uid_t *ulist) 412 411 { 413 register struct passwd *w;/* info about group member */412 struct passwd *w; /* info about group member */ 414 413 register uid_t *u; /* points to current ulist member */ 415 414 register char **p; /* points to current group member */ 416 register struct group *g;/* pointer to group information */415 struct group *g; /* pointer to group information */ 417 416 418 417 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) … … 494 493 int onlytrustedingrp(gid_t grp, uid_t *ulist) 495 494 { 496 register struct passwd *w;/* info about group member */495 struct passwd *w; /* info about group member */ 497 496 register uid_t *u; /* points to current ulist member */ 498 497 register char **p; /* points to current group member */ 499 register struct group *g;/* pointer to group information */498 struct group *g; /* pointer to group information */ 500 499 register int flag = -1; /* group member found */ 501 500 … … 503 502 struct group gr; 504 503 char buffer[SH_GRBUF_SIZE]; 505 struct grouppw;504 struct passwd pw; 506 505 char pbuffer[SH_PWBUF_SIZE]; 507 506 #endif
Note:
See TracChangeset
for help on using the changeset viewer.