Changeset 227 for trunk/src/sh_unix.c
- Timestamp:
- Apr 20, 2009, 5:59:31 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/sh_unix.c
r221 r227 990 990 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 991 991 struct passwd pwd; 992 char buffer[SH_PWBUF_SIZE];992 char * buffer; 993 993 #endif 994 994 … … 998 998 */ 999 999 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1000 sh_getpwnam_r(c, &pwd, buffer, sizeof(buffer), &w); 1000 buffer = SH_ALLOC(SH_PWBUF_SIZE); 1001 sh_getpwnam_r(c, &pwd, buffer, SH_PWBUF_SIZE, &w); 1001 1002 #else 1002 1003 w = sh_getpwnam(c); … … 1014 1015 sh_error_handle ((-1), FIL__, __LINE__, EINVAL, MSG_EINVALS, 1015 1016 _("add trusted user"), c); 1017 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1018 SH_FREE(buffer); 1019 #endif 1016 1020 SL_RETURN((-1), _("tf_add_trusted_user_int")); 1017 1021 1018 1022 succe: 1019 1023 count = sl_trust_add_user(pwid); 1024 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1025 SH_FREE(buffer); 1026 #endif 1020 1027 SL_RETURN((count), _("tf_add_trusted_user_int")); 1021 1028 } … … 1092 1099 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1093 1100 struct passwd pwd; 1094 char buffer[SH_PWBUF_SIZE];1101 char * buffer = SH_ALLOC(SH_PWBUF_SIZE); 1095 1102 struct passwd * tempres; 1096 sh_getpwnam_r(DEFAULT_IDENT, &pwd, buffer, sizeof(buffer), &tempres);1103 sh_getpwnam_r(DEFAULT_IDENT, &pwd, buffer, SH_PWBUF_SIZE, &tempres); 1097 1104 #else 1098 1105 struct passwd * tempres = sh_getpwnam(DEFAULT_IDENT); … … 1107 1114 } 1108 1115 ff_euid = tempres->pw_uid; 1116 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 1117 SH_FREE(buffer); 1118 #endif 1109 1119 } 1110 1120 #endif … … 2469 2479 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWUID_R) 2470 2480 struct passwd pwd; 2471 char buffer[SH_PWBUF_SIZE];2481 char * buffer; 2472 2482 #endif 2473 2483 char errbuf[SH_ERRBUF_SIZE]; … … 2476 2486 2477 2487 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWUID_R) 2478 sh_getpwuid_r(uid, &pwd, buffer, sizeof(buffer), &tempres); 2488 buffer = SH_ALLOC(SH_PWBUF_SIZE); 2489 sh_getpwuid_r(uid, &pwd, buffer, SH_PWBUF_SIZE, &tempres); 2479 2490 #else 2480 2491 errno = 0; … … 2487 2498 sh_error_message(status, errbuf, sizeof(errbuf)), 2488 2499 _("getpwuid"), (long) uid, _("completely missing")); 2500 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2501 SH_FREE(buffer); 2502 #endif 2489 2503 SL_RETURN( NULL, _("sh_unix_getUIDdir")); 2490 2504 } … … 2492 2506 if (tempres->pw_dir != NULL) { 2493 2507 sl_strlcpy(out, tempres->pw_dir, len); 2508 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2509 SH_FREE(buffer); 2510 #endif 2494 2511 SL_RETURN( out, _("sh_unix_getUIDdir")); 2495 2512 } else { … … 2497 2514 sh_error_message(status, errbuf, sizeof(errbuf)), 2498 2515 _("getpwuid"), (long) uid, _("pw_dir")); 2516 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2517 SH_FREE(buffer); 2518 #endif 2499 2519 SL_RETURN( NULL, _("sh_unix_getUIDdir")); 2500 2520 } … … 2508 2528 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWUID_R) 2509 2529 struct passwd pwd; 2510 char buffer[SH_PWBUF_SIZE];2530 char * buffer; 2511 2531 #endif 2512 2532 int status = 0; … … 2529 2549 2530 2550 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWUID_R) 2531 sh_getpwuid_r(uid, &pwd, buffer, sizeof(buffer), &tempres); 2551 buffer = SH_ALLOC(SH_PWBUF_SIZE); 2552 sh_getpwuid_r(uid, &pwd, buffer, SH_PWBUF_SIZE, &tempres); 2532 2553 #else 2533 2554 errno = 0; … … 2540 2561 sh_error_message(status, errbuf, sizeof(errbuf)), 2541 2562 _("getpwuid"), (long) uid, _("completely missing")); 2563 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2564 SH_FREE(buffer); 2565 #endif 2542 2566 SL_RETURN( NULL, _("sh_unix_getUIDname")); 2543 2567 } … … 2550 2574 sl_strlcpy(out, name, len); 2551 2575 SH_MUTEX_UNLOCK_UNSAFE(mutex_getUIDname); 2576 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2577 SH_FREE(buffer); 2578 #endif 2552 2579 SL_RETURN( out, _("sh_unix_getUIDname")); 2553 2580 } else { … … 2555 2582 sh_error_message(status, errbuf, sizeof(errbuf)), 2556 2583 _("getpwuid"), (long) uid, _("pw_user")); 2584 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2585 SH_FREE(buffer); 2586 #endif 2557 2587 SL_RETURN( NULL, _("sh_unix_getUIDname")); 2558 2588 } … … 2569 2599 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2570 2600 struct group grp; 2571 char buffer[SH_GRBUF_SIZE];2601 char * buffer; 2572 2602 #endif 2573 2603 char errbuf[SH_ERRBUF_SIZE]; … … 2588 2618 2589 2619 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2590 status = sh_getgrgid_r(gid, &grp, buffer, sizeof(buffer), &tempres); 2620 buffer = SH_ALLOC(SH_GRBUF_SIZE); 2621 status = sh_getgrgid_r(gid, &grp, buffer, SH_GRBUF_SIZE, &tempres); 2591 2622 #else 2592 2623 errno = 0; … … 2600 2631 _("getgrgid"), (long) gid, _("completely missing")); 2601 2632 2633 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2634 SH_FREE(buffer); 2635 #endif 2602 2636 SL_RETURN( NULL, _("sh_unix_getGIDname")); 2603 2637 } … … 2609 2643 sl_strlcpy(out, name, len); 2610 2644 SH_MUTEX_UNLOCK_UNSAFE(mutex_getGIDname); 2645 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2646 SH_FREE(buffer); 2647 #endif 2611 2648 SL_RETURN( out, _("sh_unix_getGIDname")); 2612 2649 } else { … … 2614 2651 sh_error_message(status, errbuf, sizeof(errbuf)), 2615 2652 _("getgrgid"), (long) gid, _("gr_name")); 2653 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2654 SH_FREE(buffer); 2655 #endif 2616 2656 SL_RETURN( NULL, _("sh_unix_getGIDname")); 2617 2657 } … … 3136 3176 char * fileHash, int alert_timeout, SL_TICKET fd) 3137 3177 { 3138 file_type tmpFile;3178 file_type * tmpFile; 3139 3179 int status; 3140 3180 3141 3181 SL_ENTER(_("sh_unix_checksum_size")); 3142 3182 3143 tmpFile.link_path = NULL; 3183 tmpFile = SH_ALLOC(sizeof(file_type)); 3184 tmpFile->link_path = NULL; 3144 3185 3145 3186 if (sh.flag.checkSum != SH_CHECK_INIT) 3146 3187 { 3147 3188 /* lookup file in database */ 3148 status = sh_hash_get_it (filename, &tmpFile);3189 status = sh_hash_get_it (filename, tmpFile); 3149 3190 if (status != 0) { 3150 3191 goto out; … … 3153 3194 else 3154 3195 { 3155 tmpFile .size = fbuf->st_size;3196 tmpFile->size = fbuf->st_size; 3156 3197 } 3157 3198 3158 3199 /* if last < current get checksum */ 3159 if (tmpFile .size < fbuf->st_size)3200 if (tmpFile->size < fbuf->st_size) 3160 3201 { 3161 3202 char hashbuf[KEYBUF_SIZE]; 3162 UINT64 local_length = (UINT64) (tmpFile .size < 0 ? 0 : tmpFile.size);3203 UINT64 local_length = (UINT64) (tmpFile->size < 0 ? 0 : tmpFile->size); 3163 3204 sl_strlcpy(fileHash, 3164 3205 sh_tiger_generic_hash (filename, fd, &(local_length), … … 3167 3208 3168 3209 /* return */ 3169 if (tmpFile.link_path) SH_FREE(tmpFile.link_path); 3210 if (tmpFile->link_path) SH_FREE(tmpFile->link_path); 3211 SH_FREE(tmpFile); 3170 3212 SL_RETURN( 0, _("sh_unix_checksum_size")); 3171 3213 } 3172 3214 3173 3215 out: 3174 if (tmpFile.link_path) SH_FREE(tmpFile.link_path); 3216 if (tmpFile->link_path) SH_FREE(tmpFile->link_path); 3217 SH_FREE(tmpFile); 3175 3218 sl_strlcpy(fileHash, SH_KEY_NULL, KEY_LEN+1); 3176 3219 SL_RETURN( -1, _("sh_unix_checksum_size"));
Note:
See TracChangeset
for help on using the changeset viewer.