Changeset 132
- Timestamp:
- Oct 23, 2007, 11:44:41 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 28 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/configure.ac
r131 r132 274 274 ttyname fchmod \ 275 275 getsid getpriority getpgid statvfs \ 276 fpathconf dirfd\276 strerror_r \ 277 277 getgrgid_r getpwnam_r getpwuid_r gmtime_r localtime_r rand_r readdir_r strtok_r 278 278 ) -
trunk/docs/TODO
r131 r132 1 1 2 sh_unix_time: not thread_safe (static buffer) 3 sh_error_message: not thread_safe (static buffer) 2 not thread-safe: checksum function (returns static memory), 3 sh_util_siggen 4 sh_util_hash_tiger 5 sh_util_hmac_tiger 4 6 5 7 check thread_safe sh_entropy 8 check thread_safe rng 6 9 7 lock NEED_LOCK10 lock globber 8 11 9 globber 12 lock sh_alloc/sh_free 10 13 11 sh_alloc/sh_free12 -
trunk/include/samhain.h
r131 r132 45 45 #define SH_GRBUF_SIZE 4096 46 46 #define SH_PWBUF_SIZE 4096 47 #define SH_ERRBUF_SIZE 64 47 48 48 49 /* Sizes for arrays (user, group, timestamp). -
trunk/include/sh_error.h
r86 r132 176 176 /* error messages 177 177 */ 178 /*@owned@*/char * sh_error_message (int tellme );178 /*@owned@*/char * sh_error_message (int tellme, char * str, size_t len); 179 179 180 180 /* switch on/off log to file temporarily -
trunk/include/sh_pthread.h
r130 r132 23 23 } while (0) 24 24 25 #define SH_MUTEX_LOCK_UNSAFE(M) pthread_mutex_lock(&(M)) 26 #define SH_MUTEX_UNLOCK_UNSAFE(M) pthread_mutex_unlock(&(M)) 25 27 26 28 #else … … 32 34 #define SH_MUTEX_LOCK(M) ((void)0) 33 35 #define SH_MUTEX_UNLOCK(M) ((void)0) 36 #define SH_MUTEX_LOCK_UNSAFE(M) ((void)0) 37 #define SH_MUTEX_UNLOCK_UNSAFE(M) ((void)0) 34 38 35 39 /* #ifdef HAVE_PTHREAD */ -
trunk/include/sh_tools.h
r27 r132 16 16 17 17 #ifdef SH_ENCRYPT 18 char * errorExplain (int err_num); 18 /* returns pointer to errbuf 19 */ 20 char * errorExplain (int err_num, char * errbuf, size_t len); 19 21 #endif 20 22 23 /* returns allocated buffer 24 */ 21 25 char * sh_tools_safe_name(const char * str, int flag); 22 26 int is_numeric (const char * address); … … 26 30 char * ecall, int * errnum, char * errmsg, int errsiz); 27 31 void delete_cache(void); 28 char * sh_tools_errmessage (int tellme); 32 33 /* returns pointer to errbuf 34 */ 35 char * sh_tools_errmessage (int tellme, char * errbuf, size_t len); 29 36 30 37 … … 41 48 int check_request_nerr (char * have, char * need); 42 49 50 /* returns allocated buffer 51 */ 43 52 char * hash_me (char * key, char * buf, int buflen); 44 53 int sh_tools_hash_vfy(char * key, char * buf, int buflen); 45 54 55 /* returns allocated buffer 56 */ 46 57 char * get_client_conf_file (char * peer, unsigned long * length); 58 59 /* returns allocated buffer 60 */ 47 61 char * get_client_data_file (char * peer, unsigned long * length); 48 62 -
trunk/include/sh_unix.h
r114 r132 291 291 int sh_unix_init(int goDaemon); 292 292 293 /* for local time use thetime = 0 294 */ 295 /*@owned@*/ char * sh_unix_time (time_t thetime);296 297 /* convert to GMT time 298 */ 299 char * sh_unix_gmttime (time_t thetime );293 /* for local time use thetime = 0, returns pointer to buffer 294 */ 295 char * sh_unix_time (time_t thetime, char * buffer, size_t len); 296 297 /* convert to GMT time, returns pointer to buffer 298 */ 299 char * sh_unix_gmttime (time_t thetime, char * buffer, size_t len); 300 300 301 301 /* effective user info … … 303 303 int sh_unix_getUser (void); 304 304 305 /* get home directory 306 */ 307 char * sh_unix_getUIDdir (int level, uid_t uid );305 /* get home directory, , returns pointer to out 306 */ 307 char * sh_unix_getUIDdir (int level, uid_t uid, char * out, size_t len); 308 308 309 309 -
trunk/include/sh_utils.h
r93 r132 43 43 } st_format; 44 44 45 /* returns allocated string 46 */ 45 47 char * sh_util_formatted (const char * fmt, st_format * ftab); 46 48 … … 60 62 int taus_seed (void); 61 63 64 /* returns allocated memory 65 */ 62 66 char * sh_util_strdup (const char * str); 67 68 /* returns allocated memory 69 */ 63 70 char * sh_util_strdup_l (const char * str, size_t len); 71 72 /* returns pointer within str 73 */ 64 74 char * sh_util_strsep (char **str, const char *delim); 65 75 66 /* compactify verbose acl text 76 /* compactify verbose acl text, returns allocated memory 67 77 */ 68 78 char * sh_util_acl_compact (char * buf, ssize_t len); … … 146 156 147 157 /* returns freshly allocated memory, return value should be free'd. 148 * Ar hument list must be NULL terminated.158 * Argument list must be NULL terminated. 149 159 */ 150 160 char * sh_util_strconcat (const char * arg1, ...) SH_GNUC_NULL_TERMINATED; -
trunk/src/sh_calls.c
r22 r132 115 115 int error; 116 116 long int val_retry = -1; 117 char errbuf[SH_ERRBUF_SIZE]; 117 118 errno = 0; 118 119 … … 126 127 if (val_retry < 0) { 127 128 sh_error_handle ((-1), file, line, error, MSG_ERR_SIGACT, 128 sh_error_message(error ),129 sh_error_message(error, errbuf, sizeof(errbuf)), 129 130 (long) signum ); 130 131 } … … 161 162 long int val_retry = 0; 162 163 static struct sockaddr_in new_addr; 164 char errbuf[SH_ERRBUF_SIZE]; 163 165 164 166 SL_ENTER(_("retry_connect")); … … 189 191 */ 190 192 sh_error_handle ((-1), file, line, error, MSG_ERR_CONNECT, 191 sh_error_message(error ),193 sh_error_message(error, errbuf, sizeof(errbuf)), 192 194 (long) sockfd, 193 195 /*@-unrecog -type@*/ … … 212 214 int error; 213 215 long int val_retry = -1; 216 char errbuf[SH_ERRBUF_SIZE]; 217 214 218 ACCEPT_TYPE_ARG3 my_addrlen = (ACCEPT_TYPE_ARG3) *addrlen; 215 219 … … 225 229 if (val_retry < 0) { 226 230 sh_error_handle ((-1), file, line, error, MSG_ERR_ACCEPT, 227 sh_error_message(error ),231 sh_error_message(error, errbuf, sizeof(errbuf)), 228 232 (long) fd ); 229 233 } … … 237 241 int error; 238 242 long int val_retry = -1; 243 char errbuf[SH_ERRBUF_SIZE]; 239 244 240 245 SL_ENTER(_("retry_lstat")); … … 245 250 error = errno; 246 251 if (val_retry < 0) { 247 (void) sl_strlcpy(aud_err_message, sh_error_message(error ), 64);252 (void) sl_strlcpy(aud_err_message, sh_error_message(error, errbuf, sizeof(errbuf)), 64); 248 253 sh_error_handle ((-1), file, line, error, MSG_ERR_LSTAT, 249 sh_error_message(error ),254 sh_error_message(error, errbuf, sizeof(errbuf)), 250 255 file_name ); 251 256 } … … 259 264 int error; 260 265 long int val_retry = -1; 266 char errbuf[SH_ERRBUF_SIZE]; 261 267 262 268 SL_ENTER(_("retry_stat")); … … 267 273 error = errno; 268 274 if (val_retry < 0) { 269 (void) sl_strlcpy(aud_err_message, sh_error_message(error ), 64);275 (void) sl_strlcpy(aud_err_message, sh_error_message(error, errbuf, sizeof(errbuf)), 64); 270 276 sh_error_handle ((-1), file, line, error, MSG_ERR_STAT, 271 sh_error_message(error ),277 sh_error_message(error, errbuf, sizeof(errbuf)), 272 278 file_name ); 273 279 } … … 280 286 int error; 281 287 long int val_retry = -1; 288 char errbuf[SH_ERRBUF_SIZE]; 282 289 283 290 SL_ENTER(_("retry_fstat")); … … 289 296 if (val_retry < 0) { 290 297 sh_error_handle ((-1), file, line, error, MSG_ERR_FSTAT, 291 sh_error_message(error ),298 sh_error_message(error, errbuf, sizeof(errbuf)), 292 299 (long) filed ); 293 300 } … … 300 307 int error; 301 308 long int val_retry = -1; 309 char errbuf[SH_ERRBUF_SIZE]; 302 310 errno = 0; 303 311 … … 319 327 if (val_retry < 0) { 320 328 sh_error_handle ((-1), file, line, error, MSG_ERR_FCNTL, 321 sh_error_message(error ),329 sh_error_message(error, errbuf, sizeof(errbuf)), 322 330 (long) fd, (long) cmd, arg ); 323 331 } … … 389 397 int i; 390 398 int error; 399 char errbuf[SH_ERRBUF_SIZE]; 391 400 392 401 SL_ENTER(_("retry_aud_execve")); … … 401 410 error = errno; 402 411 if (i < 0) { 403 sh_error_handle ((-1), file, line, error, MSG_ERR_EXEC, sh_error_message(error), 412 sh_error_handle ((-1), file, line, error, MSG_ERR_EXEC, 413 sh_error_message(error, errbuf, sizeof(errbuf)), 404 414 dateiname, (long) a, (long) b ); 405 415 } … … 414 424 long int val_return; 415 425 int error; 426 char errbuf[SH_ERRBUF_SIZE]; 416 427 errno = 0; 417 428 … … 430 441 if (val_return < 0) { 431 442 sh_error_handle ((-1), file, line, error, MSG_ERR_UTIME, 432 sh_error_message(error ),443 sh_error_message(error, errbuf, sizeof(errbuf)), 433 444 path, 434 445 (unsigned long) buf->actime, … … 444 455 long int val_return; 445 456 int error; 457 char errbuf[SH_ERRBUF_SIZE]; 446 458 errno = 0; 447 459 … … 457 469 path); 458 470 if (val_return < 0) { 459 sh_error_handle ((-1), file, line, error, MSG_ERR_UNLINK, sh_error_message(error), 471 sh_error_handle ((-1), file, line, error, MSG_ERR_UNLINK, 472 sh_error_message(error, errbuf, sizeof(errbuf)), 460 473 path); 461 474 } … … 469 482 long int val_return; 470 483 int error; 484 char errbuf[SH_ERRBUF_SIZE]; 471 485 errno = 0; 472 486 … … 483 497 if (val_return < 0) { 484 498 sh_error_handle ((-1), file, line, error, MSG_ERR_DUP, 485 sh_error_message(error ),499 sh_error_message(error, errbuf, sizeof(errbuf)), 486 500 (long) fd, val_return); 487 501 } … … 495 509 long int val_return; 496 510 int error; 511 char errbuf[SH_ERRBUF_SIZE]; 497 512 errno = 0; 498 513 … … 508 523 if (val_return < 0) { 509 524 sh_error_handle ((-1), file, line, error, MSG_ERR_DUP, 510 sh_error_message(error ),525 sh_error_message(error, errbuf, sizeof(errbuf)), 511 526 (long) fd, val_return); 512 527 } … … 522 537 long int val_return; 523 538 int error = 0; 539 char errbuf[SH_ERRBUF_SIZE]; 524 540 errno = 0; 525 541 … … 535 551 path); 536 552 if (val_return < 0) { 537 sh_error_handle ((-1), file, line, error, MSG_ERR_CHDIR, sh_error_message(error), 553 sh_error_handle ((-1), file, line, error, MSG_ERR_CHDIR, 554 sh_error_message(error, errbuf, sizeof(errbuf)), 538 555 path); 539 556 } … … 549 566 long int val_return; 550 567 int error; 568 char errbuf[SH_ERRBUF_SIZE]; 551 569 552 570 SL_ENTER(_("aud_open")); … … 566 584 if (val_return < 0) 567 585 { 568 (void) sl_strlcpy(aud_err_message, sh_error_message(error ), 64);586 (void) sl_strlcpy(aud_err_message, sh_error_message(error, errbuf, sizeof(errbuf)), 64); 569 587 } 570 588 … … 576 594 if (val_return < 0) { 577 595 sh_error_handle ((-1), file, line, error, MSG_ERR_OPEN, 578 sh_error_message(error ),596 sh_error_message(error, errbuf, sizeof(errbuf)), 579 597 pathname, (long) flags, (long) mode, val_return); 580 598 } … … 588 606 long int val_return; 589 607 int error; 608 char errbuf[SH_ERRBUF_SIZE]; 590 609 591 610 SL_ENTER(_("aud_open")); … … 599 618 if (val_return < 0) 600 619 { 601 (void) sl_strlcpy(aud_err_message, sh_error_message(error ), 64);620 (void) sl_strlcpy(aud_err_message, sh_error_message(error, errbuf, sizeof(errbuf)), 64); 602 621 } 603 622 … … 609 628 if (val_return < 0) { 610 629 sh_error_handle ((-1), file, line, error, MSG_ERR_OPEN, 611 sh_error_message(error ),630 sh_error_message(error, errbuf, sizeof(errbuf)), 612 631 pathname, (long) flags, (long) mode, val_return); 613 632 } … … 620 639 int myerror; 621 640 long int val_return = kill (pid, sig); 641 char errbuf[SH_ERRBUF_SIZE]; 622 642 myerror = errno; 623 643 … … 629 649 if (val_return < 0) { 630 650 sh_error_handle ((-1), file, line, myerror, MSG_ERR_KILL, 631 sh_error_message(myerror ),651 sh_error_message(myerror, errbuf, sizeof(errbuf)), 632 652 (long) pid, (long) sig); 633 653 } … … 666 686 int error; 667 687 pid_t i = fork(); 688 char errbuf[SH_ERRBUF_SIZE]; 668 689 669 690 error = errno; … … 675 696 if (i == (pid_t) -1) { 676 697 sh_error_handle ((-1), file, line, error, MSG_ERR_FORK, 677 sh_error_message(error ),698 sh_error_message(error, errbuf, sizeof(errbuf)), 678 699 (long) i); 679 700 } … … 686 707 int error = 0; 687 708 int i = 0; 709 char errbuf[SH_ERRBUF_SIZE]; 688 710 689 711 SL_ENTER(_("aud_setuid")); … … 702 724 if (i < 0) { 703 725 sh_error_handle ((-1), file, line, error, MSG_ERR_SETUID, 704 sh_error_message(error ),726 sh_error_message(error, errbuf, sizeof(errbuf)), 705 727 (long) uid); 706 728 } … … 713 735 int error = 0; 714 736 int i = 0; 737 char errbuf[SH_ERRBUF_SIZE]; 715 738 716 739 SL_ENTER(_("aud_setgid")); … … 730 753 if (i < 0) { 731 754 sh_error_handle ((-1), file, line, error, MSG_ERR_SETGID, 732 sh_error_message(error ),755 sh_error_message(error, errbuf, sizeof(errbuf)), 733 756 (long) gid); 734 757 } … … 741 764 int error; 742 765 int i = pipe (modus); 766 char errbuf[SH_ERRBUF_SIZE]; 743 767 744 768 SL_ENTER(_("aud_pipe")); … … 761 785 else 762 786 sh_error_handle ((-1), file, line, error, MSG_ERR_PIPE, 763 sh_error_message(error ),787 sh_error_message(error, errbuf, sizeof(errbuf)), 764 788 (long) modus[0], (long) modus[1]); 765 789 } -
trunk/src/sh_entropy.c
r131 r132 645 645 int retval; 646 646 char msg[128]; 647 char errbuf[SH_ERRBUF_SIZE]; 647 648 648 649 SL_ENTER(_("sh_pclose")); … … 653 654 sh_error_handle (SH_ERR_ALL, FIL__, __LINE__, retval, 654 655 MSG_E_SUBGEN, 655 sh_error_message(retval ),656 sh_error_message(retval, errbuf, sizeof(errbuf)), 656 657 _("sh_pclose")); 657 658 SL_RETURN((-1), _("sh_pclose")); … … 663 664 sh_error_handle (SH_ERR_ALL, FIL__, __LINE__, retval, 664 665 MSG_E_SUBGEN, 665 sh_error_message(retval ),666 sh_error_message(retval, errbuf, sizeof(errbuf)), 666 667 _("sh_pclose")); 667 668 … … 707 708 int maxFD = 0; 708 709 int imax, selcount; 709 710 char errbuf[SH_ERRBUF_SIZE]; 711 710 712 SL_ENTER(_("sh_entropy")); 711 713 … … 738 740 { 739 741 sh_error_handle((-1), FIL__, __LINE__, caperr, MSG_E_SUBGEN, 740 sh_error_message (caperr ),742 sh_error_message (caperr, errbuf, sizeof(errbuf)), 741 743 _("sl_get_cap_sub")); 742 744 } … … 876 878 { 877 879 sh_error_handle((-1), FIL__, __LINE__, caperr, MSG_E_SUBGEN, 878 sh_error_message (caperr ),880 sh_error_message (caperr, errbuf, sizeof(errbuf)), 879 881 _("sl_drop_cap_sub")); 880 882 } -
trunk/src/sh_err_console.c
r22 r132 70 70 key_t key; 71 71 int error; 72 char errbuf[SH_ERRBUF_SIZE]; 72 73 73 74 SL_ENTER(_("open_ipc")); … … 80 81 error = errno; 81 82 TPT(( 0, FIL__, __LINE__, _("msg=<ftok: %s> errno=<%d>\n"), 82 sh_error_message(error ), error));83 sh_error_message(error, errbuf, sizeof(errbuf)), error)); 83 84 SL_RETURN(-1, _("open_ipc")); 84 85 } … … 92 93 error = errno; 93 94 TPT(( 0, FIL__, __LINE__, _("msg=<msgget: %s> errno=<%d>\n"), 94 sh_error_message(error ), error));95 sh_error_message(error, errbuf, sizeof(errbuf)), error)); 95 96 SL_RETURN(-1, _("open_ipc")); 96 97 } … … 131 132 int error; 132 133 int count = 0; 134 char errbuf[SH_ERRBUF_SIZE]; 133 135 134 136 SL_ENTER(_("push_message_queue")); … … 201 203 error = errno; 202 204 TPT(( 0, FIL__, __LINE__, _("msg=<msgsnd: %s> errno=<%d>\n"), 203 sh_error_message(error ), error));205 sh_error_message(error, errbuf, sizeof(errbuf)), error)); 204 206 SH_FREE(recv_msg); 205 207 SL_RETURN(-1, _("push_message_queue")); -
trunk/src/sh_err_log.c
r34 r132 885 885 /* Send out the key. 886 886 */ 887 (void) s l_strlcpy(log_msg.timestamp, sh_unix_time(0), KEY_LEN+1);887 (void) sh_unix_time(0, log_msg.timestamp, KEY_LEN+1); 888 888 889 889 store1 = errFlags.loglevel; -
trunk/src/sh_error.c
r131 r132 20 20 #include "config_xor.h" 21 21 22 /* required on linux to get the correct strerror_r function 23 */ 24 #define _XOPEN_SOURCE 600 25 #include <string.h> 22 26 #include <stdio.h> 23 27 #include <stdlib.h> 24 28 #include <stdarg.h> 25 #include <string.h>26 29 #include <ctype.h> 27 30 #include <limits.h> … … 335 338 336 339 337 /*@owned@*/char * sh_error_message (int tellme) 338 { 339 340 #if defined(HAVE_STRERROR) 341 /*@i@*/return strerror(tellme); 340 char * sh_error_message (int tellme, char * str, size_t len) 341 { 342 343 #if defined(HAVE_STRERROR_R) 344 strerror_r(tellme, str, len); 345 return str; 346 #elif defined(HAVE_STRERROR) 347 sl_strlcpy(str, strerror(tellme), len); 348 return str; 342 349 #else 343 350 351 char *p = NULL; 344 352 #ifdef EACCES 345 if (tellme == EACCES) return_("Permission denied.");353 if (tellme == EACCES) p = _("Permission denied."); 346 354 #endif 347 355 #ifdef EAGAIN 348 if (tellme == EAGAIN) return_("Try again.");356 if (tellme == EAGAIN) p = _("Try again."); 349 357 #endif 350 358 #ifdef EBADF 351 if (tellme == EBADF) return_("File descriptor in bad state.");359 if (tellme == EBADF) p = _("File descriptor in bad state."); 352 360 #endif 353 361 #ifdef EEXIST 354 if (tellme == EEXIST) return_("File exists.");362 if (tellme == EEXIST) p = _("File exists."); 355 363 #endif 356 364 #ifdef EFAULT 357 if (tellme == EFAULT) return_("Bad address.");365 if (tellme == EFAULT) p = _("Bad address."); 358 366 #endif 359 367 #ifdef EINVAL 360 if (tellme == EINVAL) return_("Invalid argument.");368 if (tellme == EINVAL) p = _("Invalid argument."); 361 369 #endif 362 370 #ifdef EISDIR 363 if (tellme == EISDIR) return_("Is a directory.");371 if (tellme == EISDIR) p = _("Is a directory."); 364 372 #endif 365 373 #ifdef EINTR 366 if (tellme == EINTR) return_("System call was interrupted.");374 if (tellme == EINTR) p = _("System call was interrupted."); 367 375 #endif 368 376 #ifdef EIO 369 if (tellme == EIO) return_("Low-level I/O error.");377 if (tellme == EIO) p = _("Low-level I/O error."); 370 378 #endif 371 379 #ifdef ELOOP 372 if (tellme == ELOOP) return_("Too many symbolic links encountered.");380 if (tellme == ELOOP) p = _("Too many symbolic links encountered."); 373 381 #endif 374 382 #ifdef EMFILE 375 if (tellme == EMFILE) return_("Too many open files.");383 if (tellme == EMFILE) p = _("Too many open files."); 376 384 #endif 377 385 #ifdef EMLINK 378 if (tellme == EMLINK) return_("Too many links.");386 if (tellme == EMLINK) p = _("Too many links."); 379 387 #endif 380 388 #ifdef ENAMETOOLONG 381 389 if (tellme == ENAMETOOLONG) 382 return_("File name too long.");390 p = _("File name too long."); 383 391 #endif 384 392 #ifdef ENFILE 385 if (tellme == ENFILE) return_("File table overflow.");393 if (tellme == ENFILE) p = _("File table overflow."); 386 394 #endif 387 395 #ifdef ENOENT 388 if (tellme == ENOENT) return_("File does not exist.");396 if (tellme == ENOENT) p = _("File does not exist."); 389 397 #endif 390 398 #ifdef ENOMEM 391 if (tellme == ENOMEM) return_("Out of memory.");399 if (tellme == ENOMEM) p = _("Out of memory."); 392 400 #endif 393 401 #ifdef ENOSPC 394 if (tellme == ENOSPC) return_("No space on device.");402 if (tellme == ENOSPC) p = _("No space on device."); 395 403 #endif 396 404 #ifdef ENOTDIR 397 if (tellme == ENOTDIR) return_("Not a directory.");405 if (tellme == ENOTDIR) p = _("Not a directory."); 398 406 #endif 399 407 #ifdef ENOTSOCK 400 if (tellme == ENOTSOCK) return_("Not a socket.");408 if (tellme == ENOTSOCK) p = _("Not a socket."); 401 409 #endif 402 410 #ifdef EOPNOTSUPP 403 if (tellme == EOPNOTSUPP) return_("Socket is not of type SOCK_STREAM.");411 if (tellme == EOPNOTSUPP) p = _("Socket is not of type SOCK_STREAM."); 404 412 #endif 405 413 #ifdef EPERM 406 if (tellme == EPERM) return_("Permission denied.");414 if (tellme == EPERM) p = _("Permission denied."); 407 415 #endif 408 416 #ifdef EPIPE 409 if (tellme == EPIPE) return_("No read on pipe.");417 if (tellme == EPIPE) p = _("No read on pipe."); 410 418 #endif 411 419 #ifdef EROFS 412 if (tellme == EROFS) return_("Read-only file system.");420 if (tellme == EROFS) p = _("Read-only file system."); 413 421 #endif 414 422 #ifdef ETXTBSY 415 if (tellme == ETXTBSY) return_("Text file busy.");423 if (tellme == ETXTBSY) p = _("Text file busy."); 416 424 #endif 417 425 #ifdef EWOULDBLOCK 418 426 if (tellme == EWOULDBLOCK) 419 return_("No connections on non-blocking socket.");427 p = _("No connections on non-blocking socket."); 420 428 #endif 421 429 #ifdef EXDEV 422 if (tellme == EXDEV) return _("Not on same file system."); 423 #endif 424 return _("Unknown error"); 430 if (tellme == EXDEV) p = _("Not on same file system."); 431 #endif 432 if (!p) p = _("Unknown error"); 433 sl_strlcpy(str, p, len); 434 return str; 425 435 #endif /* ifndef HAVE_STRERROR */ 426 436 } … … 1477 1487 } 1478 1488 1479 (void) s l_strlcpy (tst, sh_unix_time (0), 64);1489 (void) sh_unix_time (0, tst, 64); 1480 1490 line = (unsigned long) lmsg->line; 1481 1491 (void) sl_strlcpy (cla, _(class_cat[lmsg->class]), 11); -
trunk/src/sh_extern.c
r131 r132 118 118 119 119 char * errfile; 120 char errbuf[SH_ERRBUF_SIZE]; 120 121 121 122 static int some_error = 0; … … 213 214 errnum = errno; 214 215 sh_error_handle((-1), FIL__, __LINE__, errnum, MSG_E_SUBGEN, 215 sh_error_message(errnum ), _("pipe"));216 sh_error_message(errnum, errbuf, sizeof(errbuf)), _("pipe")); 216 217 SL_RETURN ((-1), _("sh_ext_popen")); 217 218 } … … 235 236 errnum = errno; 236 237 sh_error_handle((-1), FIL__, __LINE__, errnum, MSG_E_SUBGEN, 237 sh_error_message(errnum ), _("fork"));238 sh_error_message(errnum, errbuf, sizeof(errbuf)), _("fork")); 238 239 SL_RETURN ((-1), _("sh_ext_popen")); 239 240 } … … 1103 1104 char * p = NULL; 1104 1105 int i; 1106 char dir[SH_PATHBUF]; 1105 1107 1106 1108 SL_ENTER(_("sh_ext_add_default")); … … 1110 1112 SL_RETURN(0, _("sh_ext_add_default")); 1111 1113 } 1112 p = sh_unix_getUIDdir (SH_ERR_ERR, (uid_t) ext_coms->tas.run_user_uid); 1114 p = sh_unix_getUIDdir (SH_ERR_ERR, (uid_t) ext_coms->tas.run_user_uid, 1115 dir, sizeof(dir)); 1113 1116 if (p) 1114 1117 (void) sh_ext_add_envv (_("HOME"), p); … … 1325 1328 int status = 0; 1326 1329 char * tmp; 1330 char errbuf[SH_ERRBUF_SIZE]; 1327 1331 1328 1332 static int some_error = 0; … … 1364 1368 { 1365 1369 sh_error_handle((-1), FIL__, __LINE__, caperr, MSG_E_SUBGEN, 1366 sh_error_message (caperr ),1370 sh_error_message (caperr, errbuf, sizeof(errbuf)), 1367 1371 _("sl_get_cap_sub")); 1368 1372 } … … 1443 1447 { 1444 1448 sh_error_handle((-1), FIL__, __LINE__, caperr, MSG_E_SUBGEN, 1445 sh_error_message (caperr ),1449 sh_error_message (caperr, errbuf, sizeof(errbuf)), 1446 1450 _("sl_drop_cap_sub")); 1447 1451 } -
trunk/src/sh_files.c
r131 r132 721 721 { 722 722 char * p; 723 char errbuf[SH_ERRBUF_SIZE]; 723 724 724 725 SL_ENTER(_("sh_files_globerr")); … … 731 732 p = sh_util_safe_name (epath); 732 733 sh_error_handle (SH_ERR_ERR, FIL__, __LINE__, errnum, MSG_FI_GLOB, 733 sh_error_message (errnum ), p);734 sh_error_message (errnum, errbuf, sizeof(errbuf)), p); 734 735 SH_FREE(p); 735 736 … … 1491 1492 char * tmpname; 1492 1493 char * tmpcat; 1494 char errbuf[SH_ERRBUF_SIZE]; 1493 1495 1494 1496 int rdepth = 0; … … 1611 1613 sh_error_handle (ShDFLevel[SH_ERR_T_DIR], FIL__, __LINE__, 0, 1612 1614 MSG_E_OPENDIR, 1613 sh_error_message (status ), tmpname);1615 sh_error_message (status, errbuf, sizeof(errbuf)), tmpname); 1614 1616 SH_FREE(tmpname); 1615 1617 -
trunk/src/sh_forward.c
r34 r132 386 386 cipherInstance cipherInst; 387 387 int err_num; 388 char expbuf[SH_ERRBUF_SIZE]; 388 389 #else 389 390 docrypt = SL_FALSE; /* dummy to fix compiler warning */ … … 422 423 if (err_num < 0) 423 424 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 424 errorExplain(err_num ),425 errorExplain(err_num, expbuf, sizeof(expbuf)), 425 426 _("sh_forward_send_intern: cipherInit")); 426 427 … … 433 434 if (err_num < 0) 434 435 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 435 errorExplain(err_num ),436 errorExplain(err_num, expbuf, sizeof(expbuf)), 436 437 _("sh_forward_send_intern: blockEncrypt")); 437 438 memcpy(q, outBlock, B_SIZ); … … 447 448 if (err_num < 0) 448 449 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 449 errorExplain(err_num ),450 errorExplain(err_num, expbuf, sizeof(expbuf)), 450 451 _("sh_forward_send_intern: blockEncrypt")); 451 452 memcpy(q, outBlock, B_SIZ); … … 549 550 cipherInstance cipherInst; 550 551 int err_num; 552 char expbuf[SH_ERRBUF_SIZE]; 551 553 #else 552 554 docrypt = SL_FALSE; /* dummy to fix compiler warning */ … … 655 657 if (err_num < 0) 656 658 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 657 errorExplain(err_num ),659 errorExplain(err_num, expbuf, sizeof(expbuf)), 658 660 _("sh_forward_receive_intern: cipherInit")); 659 661 … … 668 670 if (err_num < 0) 669 671 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 670 errorExplain(err_num ),672 errorExplain(err_num, expbuf, sizeof(expbuf)), 671 673 _("sh_forward_receive_intern: blockDecrypt")); 672 674 memcpy(q, outBlock, B_SIZ); … … 881 883 #ifdef SH_ENCRYPT 882 884 int err_num; 885 char expbuf[SH_ERRBUF_SIZE]; 883 886 #endif 884 887 … … 1053 1056 if (err_num < 0) 1054 1057 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 1055 errorExplain(err_num ),1058 errorExplain(err_num, expbuf, sizeof(expbuf)), 1056 1059 _("sh_forward_try_impl: makeKey")); 1057 1060 … … 1060 1063 if (err_num < 0) 1061 1064 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 1062 errorExplain(err_num ),1065 errorExplain(err_num, expbuf, sizeof(expbuf)), 1063 1066 _("sh_forward_try_impl: make_key")); 1064 1067 #endif … … 1233 1236 sh_error_handle((-1), FIL__, __LINE__, -1, 1234 1237 MSG_E_SUBGEN, 1235 errorExplain(err_num ),1238 errorExplain(err_num, expbuf, sizeof(expbuf)), 1236 1239 _("sh_forward_try_impl: makeKey")); 1237 1240 err_num = makeKey(&(skey->keyInstD), … … 1241 1244 sh_error_handle((-1), FIL__, __LINE__, -1, 1242 1245 MSG_E_SUBGEN, 1243 errorExplain(err_num ),1246 errorExplain(err_num, expbuf, sizeof(expbuf)), 1244 1247 _("sh_forward_try_impl: makeKey")); 1245 1248 #endif … … 1741 1744 if (flag_err != 0) 1742 1745 { 1746 char errbuf[SH_ERRBUF_SIZE]; 1743 1747 conn_state = BAD; 1744 1748 timeout_val *= 2; 1745 if (flag_err < 0 || NULL == sh_error_message(flag_err ))1749 if (flag_err < 0 || NULL == sh_error_message(flag_err, errbuf, sizeof(errbuf))) 1746 1750 flag_err = EIO; 1747 1751 sh_error_handle((-1), FIL__, __LINE__, flag_err, MSG_TCP_ECONN, 1748 sh_error_message(flag_err ));1752 sh_error_message(flag_err, errbuf, sizeof(errbuf))); 1749 1753 SL_RETURN( (-1), _("sh_forward_try_impl")); 1750 1754 } … … 2053 2057 for (i = 0; i < CLT_MAX; ++i) 2054 2058 newclt->status_arr[i] = CLT_INACTIVE; 2055 sl_strlcpy(newclt->timestamp[CLT_INACTIVE], sh_unix_time(0), TIM_MAX);2059 (void) sh_unix_time(0, newclt->timestamp[CLT_INACTIVE], TIM_MAX); 2056 2060 /* truncate */ 2057 2061 sl_strlcpy(newclt->hostname, &str[0], sep[0]+1); … … 2257 2261 cipherInstance cipherInst; 2258 2262 int err_num; 2263 char expbuf[SH_ERRBUF_SIZE]; 2259 2264 #else 2260 2265 (void) docrypt; … … 2329 2334 if (err_num < 0) 2330 2335 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 2331 errorExplain(err_num ),2336 errorExplain(err_num, expbuf, sizeof(expbuf)), 2332 2337 _("sh_forward_prep_send_int: cipherInit")); 2333 2338 … … 2339 2344 if (err_num < 0) 2340 2345 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 2341 errorExplain(err_num ),2346 errorExplain(err_num, expbuf, sizeof(expbuf)), 2342 2347 _("sh_forward_prep_send_int: blockEncrypt")); 2343 2348 memcpy(q, outBlock, B_SIZ); … … 2355 2360 if (err_num < 0) 2356 2361 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 2357 errorExplain(err_num ),2362 errorExplain(err_num, expbuf, sizeof(expbuf)), 2358 2363 _("sh_forward_prep_send_int: blockEncrypt")); 2359 2364 memcpy(q, outBlock, B_SIZ); … … 2438 2443 conn->status_now = status; 2439 2444 conn->status_arr[status] = status; 2440 sl_strlcpy(conn->timestamp[status], 2441 sh_unix_time(0), 2442 TIM_MAX); 2445 (void) sh_unix_time(0, conn->timestamp[status], TIM_MAX); 2443 2446 2444 2447 #if defined(WITH_EXTERNAL) … … 2806 2809 int send_bytes; 2807 2810 int err_num; 2811 char expbuf[SH_ERRBUF_SIZE]; 2808 2812 #endif 2809 2813 … … 3880 3884 if (err_num < 0) 3881 3885 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 3882 errorExplain(err_num ),3886 errorExplain(err_num, expbuf, sizeof(expbuf)), 3883 3887 _("check_protocol: makeKey")); 3884 3888 err_num = makeKey(&(conn->client_entry->keyInstD), … … 3887 3891 if (err_num < 0) 3888 3892 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 3889 errorExplain(err_num ),3893 errorExplain(err_num, expbuf, sizeof(expbuf)), 3890 3894 _("check_protocol: makeKey")); 3891 3895 #endif … … 4211 4215 if (err_num < 0) 4212 4216 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 4213 errorExplain(err_num ),4217 errorExplain(err_num, expbuf, sizeof(expbuf)), 4214 4218 _("sh_forward_prep_send_int: makeKey")); 4215 4219 err_num = makeKey(&(conn->client_entry->keyInstD), … … 4218 4222 if (err_num < 0) 4219 4223 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 4220 errorExplain(err_num ),4224 errorExplain(err_num, expbuf, sizeof(expbuf)), 4221 4225 _("sh_forward_prep_send_int: makeKey")); 4222 4226 #endif … … 4312 4316 cipherInstance cipherInst; 4313 4317 int err_num; 4318 char expbuf[SH_ERRBUF_SIZE]; 4314 4319 #endif 4315 4320 … … 4410 4415 if (err_num < 0) 4411 4416 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 4412 errorExplain(err_num ),4417 errorExplain(err_num, expbuf, sizeof(expbuf)), 4413 4418 _("sh_forward_do_read: cipherInit")); 4414 4419 … … 4422 4427 sh_error_handle((-1), FIL__, __LINE__, -1, 4423 4428 MSG_E_SUBGEN, 4424 errorExplain(err_num ),4429 errorExplain(err_num, expbuf, sizeof(expbuf)), 4425 4430 _("sh_forward_do_read: blockDecrypt")); 4426 4431 memcpy(q, outBlock, B_SIZ); … … 4650 4655 else 4651 4656 { 4657 char err_buf[SH_ERRBUF_SIZE]; 4652 4658 errflag = errno; 4653 4659 sh_error_handle((-1), FIL__, __LINE__, 0, MSG_E_SUBGEN, 4654 sh_error_message(errflag ), _("accept"));4660 sh_error_message(errflag,err_buf, sizeof(err_buf)), _("accept")); 4655 4661 newconn->fd = -1; 4656 4662 newconn->state = CONN_FREE; … … 4732 4738 int sh_forward_printerr_final(int slot) 4733 4739 { 4740 char errbuf[SH_ERRBUF_SIZE]; 4741 4734 4742 SL_ENTER(_("sh_forward_printerr_final")); 4735 4743 if (sock_err[slot].msg[0] != '\0') … … 4737 4745 dlog(1, FIL__, __LINE__, 4738 4746 _("Could not set up the listening socket for the server because of the\nfollowing error: %s\nPossible reasons include:\n - insufficient privilege for UID %d, or\n - the port %d is already used by another program.\n"), 4739 sh_error_message(sock_err[slot].errnum), sock_err[slot].euid, 4747 sh_error_message(sock_err[slot].errnum, errbuf, sizeof(errbuf)), 4748 sock_err[slot].euid, 4740 4749 sock_err[slot].port); 4741 4750 sh_error_handle((-1), FIL__, sock_err[slot].line, 4742 4751 sock_err[slot].errnum, MSG_EXIT_ABORTS, 4743 sh_error_message(sock_err[slot].errnum ),4752 sh_error_message(sock_err[slot].errnum, errbuf, sizeof(errbuf)), 4744 4753 sh.prg_name, 4745 4754 sock_err[slot].msg); … … 5180 5189 if ( num_sel < 0 ) /* some error */ 5181 5190 { 5191 char errbuf[SH_ERRBUF_SIZE]; 5192 5182 5193 if (sig_raised == 1) 5183 5194 { … … 5207 5218 5208 5219 sh_error_handle((-1), FIL__, __LINE__, errnum, MSG_EXIT_ABORTS, 5209 sh_error_message(errnum ),5220 sh_error_message(errnum, errbuf, sizeof(errbuf)), 5210 5221 sh.prg_name, 5211 5222 _("select")); … … 5535 5546 char buf[1048]; 5536 5547 struct sockaddr_in from; 5548 char errbuf[SH_ERRBUF_SIZE]; 5537 5549 5538 5550 /* The 6th argument in recvfrom is *socklen_t in Linux and *BSD, … … 5575 5587 TPT(( 0, FIL__, __LINE__, _("msg=<UDP error: %d>\n"), res)); 5576 5588 sh_error_handle((-1), FIL__, __LINE__, res, MSG_ERR_SYSLOG, 5577 sh_error_message(res), my_inet_ntoa(from.sin_addr)); 5589 sh_error_message(res, errbuf, sizeof(errbuf)), 5590 my_inet_ntoa(from.sin_addr)); 5578 5591 SL_RETURN( (-1), _("recv_syslog_socket")); 5579 5592 } … … 5634 5647 TPT(( 0, FIL__, __LINE__, _("msg=<UDP error: %d>\n"), res)); 5635 5648 sh_error_handle((-1), FIL__, __LINE__, res, MSG_ERR_SYSLOG, 5636 sh_error_message(res), my_inet_ntoa(from.sin_addr)); 5649 sh_error_message(res, errbuf, sizeof(errbuf)), 5650 my_inet_ntoa(from.sin_addr)); 5637 5651 5638 5652 /* don't accept anything the next 2 seconds -
trunk/src/sh_gpg.c
r131 r132 660 660 if (0 != retry_lstat(FIL__, __LINE__, DEFAULT_GPG_PATH, &buf)) 661 661 { 662 char errbuf[SH_ERRBUF_SIZE]; 663 662 664 status = errno; 663 665 sh_error_handle(SH_ERR_ERR, FIL__, __LINE__, status, MSG_ERR_LSTAT, 664 sh_error_message(status ), DEFAULT_GPG_PATH);666 sh_error_message(status, errbuf, sizeof(errbuf)), DEFAULT_GPG_PATH); 665 667 SL_RETURN( SH_GPG_BAD, _("sh_gpg_check_file_sign")); 666 668 } … … 690 692 if (0 != retry_lstat(FIL__, __LINE__, DEFAULT_PGP_PATH, &buf)) 691 693 { 694 char errbuf[SH_ERRBUF_SIZE]; 695 692 696 status = errno; 693 697 sh_error_handle(SH_ERR_ERR, FIL__, __LINE__, status, MSG_ERR_LSTAT, 694 sh_error_message(status ), DEFAULT_PGP_PATH);698 sh_error_message(status, errbuf, sizeof(errbuf)), DEFAULT_PGP_PATH); 695 699 SL_RETURN( SH_GPG_BAD, _("sh_gpg_check_file_sign")); 696 700 } -
trunk/src/sh_hash.c
r131 r132 1404 1404 1405 1405 char timestring[81]; 1406 char * timep;1407 1406 1408 1407 #if !defined(__linux__) && !defined(HAVE_STAT_FLAGS) … … 1706 1705 sl_strlen(sh_db_version_string)); 1707 1706 sl_write (pushdata_fd, _(" Date "), 6); 1708 timep = sh_unix_time(0); 1709 sl_strlcpy(timestring, timep, sizeof(timestring)); 1707 (void) sh_unix_time(0, timestring, sizeof(timestring)); 1710 1708 sl_write (pushdata_fd, timestring, sl_strlen(timestring)); 1711 1709 sl_write (pushdata_fd, "\n", 1); … … 1716 1714 printf ("%s", sh_db_version_string); 1717 1715 printf (_(" Date ")); 1718 timep = sh_unix_time(0); 1719 sl_strlcpy(timestring, timep, sizeof(timestring)); 1716 (void) sh_unix_time(0, timestring, sizeof(timestring)); 1720 1717 printf ("%s\n", timestring); 1721 1718 } … … 2343 2340 2344 2341 2345 sl_strlcpy (timstr1c, sh_unix_gmttime (theFile->ctime), 32);2342 (void) sh_unix_gmttime (theFile->ctime, timstr1c, sizeof(timstr1c)); 2346 2343 if (is_new) 2347 2344 sl_snprintf(tmp, SH_BUFSIZE, _("ctime_new=\"%s\" "), timstr1c); … … 2350 2347 sl_strlcat(msg, tmp, SH_BUFSIZE); 2351 2348 2352 sl_strlcpy (timstr1a, sh_unix_gmttime (theFile->atime), 32);2349 (void) sh_unix_gmttime (theFile->atime, timstr1a, sizeof(timstr1a)); 2353 2350 if (is_new) 2354 2351 sl_snprintf(tmp, SH_BUFSIZE, _("atime_new=\"%s\" "), timstr1a); … … 2357 2354 sl_strlcat(msg, tmp, SH_BUFSIZE); 2358 2355 2359 sl_strlcpy (timstr1m, sh_unix_gmttime (theFile->mtime), 32);2356 (void) sh_unix_gmttime (theFile->mtime, timstr1m, sizeof(timstr1m)); 2360 2357 if (is_new) 2361 2358 sl_snprintf(tmp, SH_BUFSIZE, _("mtime_new=\"%s\" "), timstr1m); … … 2509 2506 2510 2507 2511 sl_strlcpy (timstr1c, sh_unix_gmttime (theFile->ctime), 32);2508 (void) sh_unix_gmttime (theFile->ctime, timstr1c, sizeof(timstr1c)); 2512 2509 if (is_new) 2513 2510 sl_snprintf(tmp, SH_BUFSIZE, _("ctime_new=<%s>, "), timstr1c); … … 2516 2513 sl_strlcat(msg, tmp, SH_BUFSIZE); 2517 2514 2518 sl_strlcpy (timstr1a, sh_unix_gmttime (theFile->atime), 32);2515 (void) sh_unix_gmttime (theFile->atime, timstr1a, sizeof(timstr1a)); 2519 2516 if (is_new) 2520 2517 sl_snprintf(tmp, SH_BUFSIZE, _("atime_new=<%s>, "), timstr1a); … … 2523 2520 sl_strlcat(msg, tmp, SH_BUFSIZE); 2524 2521 2525 sl_strlcpy (timstr1m, sh_unix_gmttime (theFile->mtime), 32);2522 (void) sh_unix_gmttime (theFile->mtime, timstr1m, sizeof(timstr1m)); 2526 2523 if (is_new) 2527 2524 sl_snprintf(tmp, SH_BUFSIZE, _("mtime_new=<%s>, "), timstr1m); … … 3145 3142 if ((modi_mask & MODI_CTM) != 0) 3146 3143 { 3147 sl_strlcpy (timstr1c, sh_unix_gmttime (p->theFile.ctime), 32);3148 sl_strlcpy (timstr2c, sh_unix_gmttime (theFile->ctime), 32);3144 (void) sh_unix_gmttime (p->theFile.ctime, timstr1c, sizeof(timstr1c)); 3145 (void) sh_unix_gmttime (theFile->ctime, timstr2c, sizeof(timstr2c)); 3149 3146 #ifdef SH_USE_XML 3150 3147 sl_snprintf(tmp, SH_BUFSIZE, _("ctime_old=\"%s\" ctime_new=\"%s\" "), … … 3163 3160 if ((modi_mask & MODI_ATM) != 0) 3164 3161 { 3165 sl_strlcpy (timstr1a, sh_unix_gmttime (p->theFile.atime), 32);3166 sl_strlcpy (timstr2a, sh_unix_gmttime (theFile->atime), 32);3162 (void) sh_unix_gmttime (p->theFile.atime, timstr1a, sizeof(timstr1a)); 3163 (void) sh_unix_gmttime (theFile->atime, timstr2a, sizeof(timstr2a)); 3167 3164 #ifdef SH_USE_XML 3168 3165 sl_snprintf(tmp, SH_BUFSIZE, _("atime_old=\"%s\" atime_new=\"%s\" "), … … 3181 3178 if ((modi_mask & MODI_MTM) != 0) 3182 3179 { 3183 sl_strlcpy (timstr1m, sh_unix_gmttime (p->theFile.mtime), 32);3184 sl_strlcpy (timstr2m, sh_unix_gmttime (theFile->mtime), 32);3180 (void) sh_unix_gmttime (p->theFile.mtime, timstr1m, sizeof(timstr1m)); 3181 (void) sh_unix_gmttime (theFile->mtime, timstr2m, sizeof(timstr2m)); 3185 3182 #ifdef SH_USE_XML 3186 3183 sl_snprintf(tmp, SH_BUFSIZE, _("mtime_old=\"%s\" mtime_new=\"%s\" "), … … 3579 3576 3580 3577 if ('c' == p->theFile.c_mode[0] || 'b' == p->theFile.c_mode[0]) 3581 sl_snprintf(str, 80, "%"PRIu64, p->theFile.rdev);3582 else 3583 sl_snprintf(str, 80, "%"PRIu64, p->theFile.size);3578 sl_snprintf(str, sizeof(str), "%"PRIu64, p->theFile.rdev); 3579 else 3580 sl_snprintf(str, sizeof(str), "%"PRIu64, p->theFile.size); 3584 3581 3585 3582 printf( _(" %8s"), str); … … 3587 3584 putchar(','); 3588 3585 3589 printf( _(" %s"), sh_unix_gmttime (p->theFile.ctime ));3586 printf( _(" %s"), sh_unix_gmttime (p->theFile.ctime, str, sizeof(str))); 3590 3587 if (ListWithDelimiter == S_TRUE) 3591 3588 putchar(','); 3592 printf( _(" %s"), sh_unix_gmttime (p->theFile.mtime ));3589 printf( _(" %s"), sh_unix_gmttime (p->theFile.mtime, str, sizeof(str))); 3593 3590 if (ListWithDelimiter == S_TRUE) 3594 3591 putchar(','); 3595 printf( _(" %s"), sh_unix_gmttime (p->theFile.atime ));3592 printf( _(" %s"), sh_unix_gmttime (p->theFile.atime, str, sizeof(str))); 3596 3593 if (ListWithDelimiter == S_TRUE) 3597 3594 putchar(','); -
trunk/src/sh_kern.c
r131 r132 1222 1222 if (mod_syscall_code != 0) 1223 1223 { 1224 sl_strlcpy (timstr_o, sh_unix_gmttime (ctime_old), 32);1225 sl_strlcpy (timstr_n, sh_unix_gmttime (ctime_new), 32);1224 (void) sh_unix_gmttime (ctime_old, timstr_o, sizeof(timstr_o)); 1225 (void) sh_unix_gmttime (ctime_new, timstr_n, sizeof(timstr_n)); 1226 1226 #ifdef SH_USE_XML 1227 1227 sl_snprintf(tmp, 128, … … 1234 1234 #endif 1235 1235 sl_strlcat(msg, tmp, SH_BUFSIZE); 1236 sl_strlcpy (timstr_o, sh_unix_gmttime (mtime_old), 32);1237 sl_strlcpy (timstr_n, sh_unix_gmttime (mtime_new), 32);1236 (void) sh_unix_gmttime (mtime_old, timstr_o, sizeof(timstr_o)); 1237 (void) sh_unix_gmttime (mtime_new, timstr_n, sizeof(timstr_n)); 1238 1238 #ifdef SH_USE_XML 1239 1239 sl_snprintf(tmp, 128, … … 1693 1693 sl_strlcpy(msg, tmp, SH_BUFSIZE); 1694 1694 1695 sl_strlcpy (timstr_o, sh_unix_gmttime (ctime_old), 32);1696 sl_strlcpy (timstr_n, sh_unix_gmttime (ctime_new), 32);1695 (void) sh_unix_gmttime (ctime_old, timstr_o, sizeof(timstr_o)); 1696 (void) sh_unix_gmttime (ctime_new, timstr_n, sizeof(timstr_n)); 1697 1697 #ifdef SH_USE_XML 1698 1698 sl_snprintf(tmp, 128, … … 1705 1705 #endif 1706 1706 sl_strlcat(msg, tmp, SH_BUFSIZE); 1707 sl_strlcpy (timstr_o, sh_unix_gmttime (mtime_old), 32);1708 sl_strlcpy (timstr_n, sh_unix_gmttime (mtime_new), 32);1707 (void) sh_unix_gmttime (mtime_old, timstr_o, sizeof(timstr_o)); 1708 (void) sh_unix_gmttime (mtime_new, timstr_n, sizeof(timstr_n)); 1709 1709 #ifdef SH_USE_XML 1710 1710 sl_snprintf(tmp, 128, -
trunk/src/sh_mail.c
r131 r132 810 810 size_t msgbufsize = SH_MAILBUF; 811 811 size_t combufsize = SH_MAILBUF; 812 char timebuf[81]; 812 813 813 814 SL_ENTER(_("sh_mail_msg")); … … 887 888 { 888 889 (void) sl_strlcpy(mheader, _("Subject: "), sizeof(mheader)-5); 889 (void) sl_strlcat(mheader, sh_unix_time (0), sizeof(mheader)-5); 890 (void) sl_strlcat(mheader, sh_unix_time (0, timebuf, sizeof(timebuf)), 891 sizeof(mheader)-5); 890 892 (void) sl_strlcat(mheader, " ", sizeof(mheader)-5); 891 893 (void) sl_strlcat(mheader, sh.host.name, sizeof(mheader)-5); … … 909 911 { 910 912 (void) sl_strlcpy(mheader, _("Subject: "), sizeof(mheader)-5); 911 (void) sl_strlcat(mheader, sh_unix_time (0), sizeof(mheader)-5); 913 (void) sl_strlcat(mheader, sh_unix_time (0, timebuf, sizeof(timebuf)), 914 sizeof(mheader)-5); 912 915 (void) sl_strlcat(mheader, " ", sizeof(mheader)-5); 913 916 (void) sl_strlcat(mheader, sh.host.name, sizeof(mheader)-5); … … 921 924 /* ---------- Message --------------------------------------- */ 922 925 923 (void) sl_strlcpy(subject, sh_unix_time (0), sizeof(subject)); 926 (void) sl_strlcpy(subject, sh_unix_time (0, timebuf, sizeof(timebuf)), 927 sizeof(subject)); 924 928 (void) sl_strlcat(subject, " ", sizeof(subject)); 925 929 (void) sl_strlcat(subject, sh.host.name, sizeof(subject)); … … 1885 1889 if (length < 1) 1886 1890 { 1891 char errbuf[SH_ERRBUF_SIZE]; 1892 1887 1893 /* error handling 1888 1894 */ … … 1897 1903 sh_error_handle (SH_ERR_ALL, FIL__, __LINE__, status, MSG_E_SUBGEN, 1898 1904 (errno == ECONNREFUSED) ? 1899 sh_error_message (status ) :1900 sh_tools_errmessage(status ),1905 sh_error_message (status, errbuf, sizeof(errbuf)) : 1906 sh_tools_errmessage(status, errbuf, sizeof(errbuf)), 1901 1907 _("res_query")); 1902 1908 #else 1903 1909 if (errno == ECONNREFUSED) 1904 fprintf(stderr, " ERROR: %s: \n", strerror(errno)); 1910 fprintf(stderr, " ERROR: %s: \n", strerror(errno)); /* TESTONLY */ 1905 1911 else 1906 fprintf(stderr, "HERROR: %s\n", hstrerror(h_errno)); 1912 fprintf(stderr, "HERROR: %s\n", hstrerror(h_errno));/* TESTONLY */ 1907 1913 #endif 1908 1914 } -
trunk/src/sh_portcheck.c
r131 r132 608 608 int nerr; 609 609 #endif 610 char errbuf[SH_ERRBUF_SIZE]; 610 611 611 612 /* inet_aton(interface, &haddr); */ … … 627 628 nerr = errno; 628 629 sl_snprintf(errmsg, sizeof(errmsg), _("check port: %5d/udp on %15s: %s"), 629 port, inet_ntoa(haddr), sh_error_message(errno ));630 port, inet_ntoa(haddr), sh_error_message(errno, errbuf, sizeof(errbuf))); 630 631 sh_error_handle((-1), FIL__, __LINE__, nerr, MSG_E_SUBGEN, 631 632 errmsg, _("connect")); … … 693 694 int nerr; 694 695 #endif 695 696 char errbuf[SH_ERRBUF_SIZE]; 696 697 697 698 /* inet_aton(interface, &haddr); */ … … 719 720 nerr = errno; 720 721 sl_snprintf(errmsg, sizeof(errmsg), _("check port: %5d/tcp on %15s: %s"), 721 port, inet_ntoa(haddr), sh_error_message(errno ));722 port, inet_ntoa(haddr), sh_error_message(errno, errbuf, sizeof(errbuf))); 722 723 sh_error_handle((-1), FIL__, __LINE__, nerr, MSG_E_SUBGEN, 723 724 errmsg, _("connect")); … … 889 890 int flag = 1; /* non-zero to enable an option */ 890 891 struct in_addr haddr; 891 892 char errbuf[SH_ERRBUF_SIZE]; 893 892 894 /* Check all interfaces for this host 893 895 */ … … 901 903 #else 902 904 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 903 sh_error_message(errno ), _("socket"));905 sh_error_message(errno, errbuf, sizeof(errbuf)), _("socket")); 904 906 #endif 905 907 } … … 912 914 #else 913 915 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 914 sh_error_message(errno ),_("setsockopt"));916 sh_error_message(errno, errbuf, sizeof(errbuf)),_("setsockopt")); 915 917 #endif 916 918 } … … 957 959 struct sockaddr_in addr; 958 960 int addrlen = sizeof(addr); 961 char errbuf[SH_ERRBUF_SIZE]; 959 962 960 963 if (min_port == -1) … … 973 976 #else 974 977 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 975 sh_error_message(errno ), _("socket"));978 sh_error_message(errno, errbuf, sizeof(errbuf)), _("socket")); 976 979 #endif 977 980 } … … 984 987 #else 985 988 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 986 sh_error_message(errno ),_("setsockopt"));989 sh_error_message(errno, errbuf, sizeof(errbuf)),_("setsockopt")); 987 990 #endif 988 991 } … … 1018 1021 #else 1019 1022 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 1020 sh_error_message(errno ), _("bind"));1023 sh_error_message(errno, errbuf, sizeof(errbuf)), _("bind")); 1021 1024 #endif 1022 1025 } -
trunk/src/sh_prelink.c
r131 r132 179 179 if (init == S_FALSE) 180 180 { 181 char dir[SH_PATHBUF]; 182 181 183 sh_ext_tas_init(&task); 182 p = sh_unix_getUIDdir (SH_ERR_ERR, task.run_user_uid );184 p = sh_unix_getUIDdir (SH_ERR_ERR, task.run_user_uid, dir, sizeof(dir)); 183 185 if (p) 184 186 { -
trunk/src/sh_processcheck.c
r103 r132 185 185 static char * get_user_and_path (pid_t pid, char * user, size_t usrlen) 186 186 { 187 extern char * sh_unix_getUIDname (int level, uid_t uid );187 extern char * sh_unix_getUIDname (int level, uid_t uid, char * out, size_t len); 188 188 189 189 char path[128]; … … 232 232 } 233 233 234 tmp = sh_unix_getUIDname (SH_ERR_ALL, sbuf.st_uid); 235 236 if (tmp) 237 sl_strlcpy(user, tmp, usrlen); 238 else 234 tmp = sh_unix_getUIDname (SH_ERR_ALL, sbuf.st_uid, user, usrlen); 235 236 if (!tmp) 239 237 sl_snprintf (user, usrlen, "%ld", (unsigned long) sbuf.st_uid); 240 238 … … 826 824 else 827 825 { 826 char errbuf[SH_ERRBUF_SIZE]; 827 828 828 sh_error_handle(SH_ERR_ALL, FIL__, __LINE__, errno, MSG_E_SUBGEN, 829 sh_error_message(errno ),829 sh_error_message(errno, errbuf, sizeof(errbuf)), 830 830 _("sh_processes_readps")); 831 831 break; … … 951 951 struct sigaction old_act; 952 952 int retval = 0; 953 char dir[SH_PATHBUF]; 953 954 954 955 SL_ENTER(_("sh_processes_runps")); 955 956 956 957 sh_ext_tas_init(&task); 957 p = sh_unix_getUIDdir (SH_ERR_ERR, task.run_user_uid );958 p = sh_unix_getUIDdir (SH_ERR_ERR, task.run_user_uid, dir, sizeof(dir)); 958 959 if (p) 959 960 { -
trunk/src/sh_socket.c
r118 r132 342 342 #endif 343 343 struct stat buf; 344 char errbuf[SH_ERRBUF_SIZE]; 344 345 345 346 SL_ENTER(_("sh_socket_open_int")); … … 364 365 { 365 366 sh_error_handle ((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 366 sh_error_message (errno ),367 sh_error_message (errno, errbuf, sizeof(errbuf)), 367 368 _("sh_socket_open_int: socket")); 368 369 SL_RETURN( (-1), _("sh_socket_open_int")); … … 405 406 close(pf_unix_fd); pf_unix_fd = -1; 406 407 sh_error_handle ((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 407 sh_error_message (errno ),408 sh_error_message (errno, errbuf, sizeof(errbuf)), 408 409 _("sh_socket_open_int: bind")); 409 410 SL_RETURN( (-1), _("sh_socket_open_int")); … … 416 417 close(pf_unix_fd); pf_unix_fd = -1; 417 418 sh_error_handle ((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 418 sh_error_message (errno ),419 sh_error_message (errno, errbuf, sizeof(errbuf)), 419 420 _("sh_socket_open_int: setsockopt")); 420 421 SL_RETURN( (-1), _("sh_socket_open_int")); … … 427 428 close(pf_unix_fd); pf_unix_fd = -1; 428 429 sh_error_handle ((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 429 sh_error_message (errno ),430 sh_error_message (errno, errbuf, sizeof(errbuf)), 430 431 _("sh_socket_open_int: fcntl1")); 431 432 SL_RETURN( (-1), _("sh_socket_open_int")); … … 437 438 close(pf_unix_fd); pf_unix_fd = -1; 438 439 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 439 sh_error_message (errno ),440 sh_error_message (errno, errbuf, sizeof(errbuf)), 440 441 _("sh_socket_open_int: fcntl2")); 441 442 SL_RETURN( (-1), _("sh_socket_open_int")); … … 446 447 close(pf_unix_fd); pf_unix_fd = -1; 447 448 sh_error_handle ((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 448 sh_error_message (errno ),449 sh_error_message (errno, errbuf, sizeof(errbuf)), 449 450 _("sh_socket_open_int: listen")); 450 451 SL_RETURN( (-1), _("sh_socket_open_int")); … … 509 510 510 511 int client_uid = -1; 512 char errbuf[SH_ERRBUF_SIZE]; 511 513 512 514 … … 588 590 { 589 591 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 590 sh_error_message (errno ),592 sh_error_message (errno, errbuf, sizeof(errbuf)), 591 593 _("sh_socket_read: accept")); 592 594 return -1; … … 602 604 { 603 605 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 604 sh_error_message (errno ),606 sh_error_message (errno, errbuf, sizeof(errbuf)), 605 607 _("sh_socket_read: setsockopt")); 606 608 close(talkfd); … … 615 617 { 616 618 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 617 sh_error_message (errno ),619 sh_error_message (errno, errbuf, sizeof(errbuf)), 618 620 _("sh_socket_read: recvmsg")); 619 621 close(talkfd); … … 644 646 } 645 647 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 646 sh_error_message (errno ),648 sh_error_message (errno, errbuf, sizeof(errbuf)), 647 649 _("sh_socket_read: recvfrom")); 648 650 close(talkfd); … … 654 656 { 655 657 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 656 sh_error_message (errno ),658 sh_error_message (errno, errbuf, sizeof(errbuf)), 657 659 _("sh_socket_read: getpeereid")); 658 660 close(talkfd); … … 665 667 { 666 668 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 667 sh_error_message (errno ),669 sh_error_message (errno, errbuf, sizeof(errbuf)), 668 670 _("sh_socket_read: getsockopt")); 669 671 close(talkfd); … … 843 845 { 844 846 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 845 sh_error_message (errno ),847 sh_error_message (errno, errbuf, sizeof(errbuf)), 846 848 _("sh_socket_read: send")); 847 849 return -1; … … 876 878 { 877 879 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 878 sh_error_message (errno ),880 sh_error_message (errno, errbuf, sizeof(errbuf)), 879 881 _("sh_socket_read: sendto")); 880 882 close(talkfd); … … 907 909 { 908 910 sh_error_handle((-1), FIL__, __LINE__, errno, MSG_E_SUBGEN, 909 sh_error_message (errno ),911 sh_error_message (errno, errbuf, sizeof(errbuf)), 910 912 _("sh_socket_read: sendto")); 911 913 close(talkfd); … … 933 935 sl_strlcpy (new->cmd, in->cmd, sizeof(new->cmd)); 934 936 sl_strlcpy (new->clt, in->clt, sizeof(new->clt)); 935 sl_strlcpy (new->cti, sh_unix_time(0), sizeof(new->cti));937 (void) sh_unix_time(0, new->cti, sizeof(new->cti)); 936 938 new->next = cmdlist; 937 939 cmdlist = new; … … 951 953 sl_strlcpy (new->cmd, in->cmd, sizeof(new->cmd)); 952 954 sl_strlcpy (new->clt, in->clt, sizeof(new->clt)); 953 sl_strlcpy (new->cti, sh_unix_time(0), sizeof(new->cti));955 (void) sh_unix_time(0, new->cti, sizeof(new->cti)); 954 956 return; 955 957 } … … 960 962 sl_strlcpy (new->cmd, in->cmd, sizeof(new->cmd)); 961 963 sl_strlcpy (new->clt, in->clt, sizeof(new->clt)); 962 sl_strlcpy (new->cti, sh_unix_time(0), sizeof(new->cti));964 (void) sh_unix_time(0, new->cti, sizeof(new->cti)); 963 965 new->next = runlist; 964 966 runlist = new; -
trunk/src/sh_suidchk.c
r131 r132 173 173 struct stat two; 174 174 int fd; 175 char errbuf[SH_ERRBUF_SIZE]; 175 176 176 177 if (depth > 99) … … 198 199 sh_error_handle ((-1), FIL__, __LINE__, errno, 199 200 MSG_SUID_ERROR, 200 sh_error_message(errno ));201 sh_error_message(errno, errbuf, sizeof(errbuf))); 201 202 *q = '/'; 202 203 return -1; … … 217 218 sh_error_handle ((-1), FIL__, __LINE__, errno, 218 219 MSG_SUID_ERROR, 219 sh_error_message(errno ));220 sh_error_message(errno, errbuf, sizeof(errbuf))); 220 221 *q = '/'; 221 222 return -1; … … 226 227 sh_error_handle ((-1), FIL__, __LINE__, errno, 227 228 MSG_SUID_ERROR, 228 sh_error_message(errno ));229 sh_error_message(errno, errbuf, sizeof(errbuf))); 229 230 return -1; 230 231 } … … 252 253 sh_error_handle ((-1), FIL__, __LINE__, errno, 253 254 MSG_SUID_ERROR, 254 sh_error_message(errno ));255 sh_error_message(errno, errbuf, sizeof(errbuf))); 255 256 return -1; 256 257 } … … 260 261 sh_error_handle ((-1), FIL__, __LINE__, errno, 261 262 MSG_SUID_ERROR, 262 sh_error_message(errno ));263 sh_error_message(errno, errbuf, sizeof(errbuf))); 263 264 return -1; 264 265 } … … 267 268 sh_error_handle ((-1), FIL__, __LINE__, errno, 268 269 MSG_SUID_ERROR, 269 sh_error_message(errno ));270 sh_error_message(errno, errbuf, sizeof(errbuf))); 270 271 (void) close(fd); 271 272 return -1; … … 307 308 sh_error_handle ((-1), FIL__, __LINE__, errno, 308 309 MSG_SUID_ERROR, 309 sh_error_message(errno ));310 sh_error_message(errno, errbuf, sizeof(errbuf))); 310 311 (void) close(fd); 311 312 return -1; … … 332 333 sh_error_handle ((-1), FIL__, __LINE__, errno, 333 334 MSG_SUID_ERROR, 334 sh_error_message(errno ));335 sh_error_message(errno, errbuf, sizeof(errbuf))); 335 336 (void) close(fd); 336 337 return -1; … … 343 344 sh_error_handle ((-1), FIL__, __LINE__, errno, 344 345 MSG_SUID_ERROR, 345 sh_error_message(errno ));346 sh_error_message(errno, errbuf, sizeof(errbuf))); 346 347 (void) close(fd); 347 348 return -1; … … 358 359 int result; 359 360 char * path; 361 char errbuf[SH_ERRBUF_SIZE]; 360 362 361 363 if (0 != chdir("/")) … … 363 365 sh_error_handle ((-1), FIL__, __LINE__, errno, 364 366 MSG_SUID_ERROR, 365 sh_error_message(errno ));367 sh_error_message(errno, errbuf, sizeof(errbuf))); 366 368 } 367 369 … … 369 371 { 370 372 sh_error_handle((-1), FIL__, __LINE__, caperr, MSG_E_SUBGEN, 371 sh_error_message (caperr ),373 sh_error_message (caperr, errbuf, sizeof(errbuf)), 372 374 _("sl_get_cap_qdel")); 373 375 } … … 380 382 { 381 383 sh_error_handle((-1), FIL__, __LINE__, caperr, MSG_E_SUBGEN, 382 sh_error_message (caperr ),384 sh_error_message (caperr, errbuf, sizeof(errbuf)), 383 385 _("sl_drop_cap_qdel")); 384 386 } … … 388 390 sh_error_handle ((-1), FIL__, __LINE__, errno, 389 391 MSG_SUID_ERROR, 390 sh_error_message(errno ));392 sh_error_message(errno, errbuf, sizeof(errbuf))); 391 393 } 392 394 return result; … … 616 618 int cperm_status = 0; 617 619 int file_d = -1; 620 char errbuf[SH_ERRBUF_SIZE]; 618 621 619 622 if (retry_lstat(FIL__, __LINE__, fullpath, &fileInfo) == -1) … … 640 643 sh_error_handle((-1), FIL__, __LINE__, 641 644 caperr, MSG_E_SUBGEN, 642 sh_error_message (caperr ),645 sh_error_message (caperr, errbuf, sizeof(errbuf)), 643 646 _("sl_get_cap_qdel")); 644 647 cperm_status = -1; … … 753 756 sh_error_handle((-1), FIL__, __LINE__, 754 757 caperr, MSG_E_SUBGEN, 755 sh_error_message (caperr ),758 sh_error_message (caperr, errbuf, sizeof(errbuf)), 756 759 _("sl_drop_cap_qdel")); 757 760 } … … 792 795 msg[0] = '\0'; 793 796 /*@-usedef@*/ 794 (void) sl_strlcpy (timestrc, 795 sh_unix_gmttime (theFile->ctime), 796 32); 797 (void) sl_strlcpy (timestra, 798 sh_unix_gmttime (theFile->atime), 799 32); 800 (void) sl_strlcpy (timestrm, 801 sh_unix_gmttime (theFile->mtime), 802 32); 797 803 798 #ifdef SH_USE_XML 804 799 (void) sl_snprintf(msg, SH_BUFSIZE, _("owner_new=\"%s\" iowner_new=\"%ld\" group_new=\"%s\" igroup_new=\"%ld\" size_new=\"%lu\" ctime_new=\"%s\" atime_new=\"%s\" mtime_new=\"%s\""), … … 845 840 struct sh_dirent * dirlist = NULL; 846 841 struct sh_dirent * dirlist_orig = NULL; 842 char errbuf[SH_ERRBUF_SIZE]; 847 843 848 844 SL_ENTER(_("sh_suidchk_check_internal")); … … 866 862 sh_error_handle (ShDFLevel[SH_ERR_T_DIR], FIL__, __LINE__, status, 867 863 MSG_E_OPENDIR, 868 sh_error_message (status ), tmp);864 sh_error_message (status, errbuf, sizeof(errbuf)), tmp); 869 865 SH_FREE(tmp); 870 866 SL_RETURN( (-1), _("sh_suidchk_check_internal")); … … 961 957 tmp = sh_util_safe_name(tmpcat); 962 958 sh_error_handle (SH_ERR_ERR, FIL__, __LINE__, status, MSG_ERR_LSTAT, 963 sh_error_message(status ),959 sh_error_message(status, errbuf, sizeof(errbuf)), 964 960 tmpcat ); 965 961 SH_FREE(tmp); … … 1083 1079 { 1084 1080 if (-1 == fflags) 1085 report_file(tmpcat, &theFile, timestrc, timestra, timestrm); 1086 1081 { 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)); 1085 1086 report_file(tmpcat, &theFile, timestrc, timestra, timestrm); 1087 } 1087 1088 /* Quarantine file according to configured method 1088 1089 */ -
trunk/src/sh_tools.c
r81 r132 94 94 #ifdef SH_ENCRYPT 95 95 #include "rijndael-api-fst.h" 96 char * errorExplain (int err_num) 97 { 96 char * errorExplain (int err_num, char * buffer, size_t len) 97 { 98 char * p; 99 98 100 if (err_num == BAD_KEY_DIR) 99 return(_("Key direction is invalid"));101 p = (_("Key direction is invalid")); 100 102 else if (err_num == BAD_KEY_MAT) 101 return(_("Key material not of correct length"));103 p = (_("Key material not of correct length")); 102 104 else if (err_num == BAD_KEY_INSTANCE) 103 return(_("Key passed is not valid"));105 p = (_("Key passed is not valid")); 104 106 else if (err_num == BAD_CIPHER_MODE) 105 return(_("Params struct passed to cipherInit invalid"));107 p = (_("Params struct passed to cipherInit invalid")); 106 108 else if (err_num == BAD_CIPHER_STATE) 107 return(_("Cipher in wrong state"));109 p = (_("Cipher in wrong state")); 108 110 else if (err_num == BAD_BLOCK_LENGTH) 109 return(_("Bad block length"));111 p = (_("Bad block length")); 110 112 else if (err_num == BAD_CIPHER_INSTANCE) 111 return(_("Bad cipher instance"));113 p = (_("Bad cipher instance")); 112 114 else if (err_num == BAD_DATA) 113 return(_("Data contents are invalid"));115 p = (_("Data contents are invalid")); 114 116 else 115 return (_("Unknown error")); 117 p = (_("Unknown error")); 118 sl_strlcpy (buffer, p, len); 119 return buffer; 116 120 } 117 121 … … 361 365 /* extern int h_errno; */ 362 366 363 char * sh_tools_errmessage (int tellme )364 { 365 367 char * sh_tools_errmessage (int tellme, char * errbuf, size_t len) 368 { 369 char * p = NULL; 366 370 #ifdef HOST_NOT_FOUND 367 371 if (tellme == HOST_NOT_FOUND) 368 return_("The specified host is unknown: ");372 p = _("The specified host is unknown: "); 369 373 #endif 370 374 #ifdef NO_ADDRESS 371 375 if (tellme == NO_ADDRESS) 372 return_("The requested name is valid but does not have an IP address: ");376 p = _("The requested name is valid but does not have an IP address: "); 373 377 #endif 374 378 #ifdef NO_RECOVERY 375 379 if (tellme == NO_RECOVERY) 376 return_("A non-recoverable name server error occurred: ");380 p = _("A non-recoverable name server error occurred: "); 377 381 #endif 378 382 #ifdef TRY_AGAIN 379 383 if (tellme == TRY_AGAIN) 380 return _("A temporary error occurred on an authoritative name server. The specified host is unknown: "); 381 #endif 382 return _("Unknown error"); 384 p = _("A temporary error occurred on an authoritative name server. The specified host is unknown: "); 385 #endif 386 if (!p) p = _("Unknown error"); 387 sl_strlcpy(errbuf, p, len); 388 return errbuf; 383 389 } 384 390 … … 474 480 475 481 int retval; 482 char errbuf[SH_ERRBUF_SIZE]; 476 483 477 484 sin_cache * check_cache = conn_cache; … … 525 532 *errnum = 666; 526 533 #endif 527 sl_strlcpy(errmsg, sh_tools_errmessage (*errnum), errsiz);534 (void) sh_tools_errmessage (*errnum, errmsg, errsiz); 528 535 sl_strlcat(errmsg, address, errsiz); 529 536 fail = (-1); … … 561 568 *errnum = 666; 562 569 #endif 563 sl_strlcpy(errmsg, 564 sh_tools_errmessage (*errnum), errsiz); 570 (void) sh_tools_errmessage (*errnum, errmsg, errsiz); 565 571 sl_strlcat(errmsg, 566 572 inet_ntoa (*(struct in_addr *) &(sinr.sin_addr)), … … 637 643 sl_strlcpy(ecall, _("socket"), SH_MINIBUF); 638 644 *errnum = status; 639 sl_strlcpy(errmsg, sh_error_message (status ), errsiz);645 sl_strlcpy(errmsg, sh_error_message (status, errbuf, sizeof(errbuf)), errsiz); 640 646 sl_strlcat(errmsg, _(", address "), errsiz); 641 647 sl_strlcat(errmsg, address, errsiz); … … 651 657 sl_strlcpy(ecall, _("connect"), SH_MINIBUF); 652 658 *errnum = status; 653 sl_strlcpy(errmsg, sh_error_message (status ), errsiz);659 sl_strlcpy(errmsg, sh_error_message (status, errbuf, sizeof(errbuf)), errsiz); 654 660 sl_strlcat(errmsg, _(", address "), errsiz); 655 661 sl_strlcat(errmsg, address, errsiz); … … 715 721 struct sigaction new_act; 716 722 struct sigaction old_act; 723 char errbuf[SH_ERRBUF_SIZE]; 717 724 718 725 SL_ENTER(_("sh_write_select")); … … 753 760 *w_error = errno; 754 761 TPT(( 0, FIL__, __LINE__, _("msg=<select: %s>\n"), 755 sh_error_message(*w_error )));762 sh_error_message(*w_error, errbuf, sizeof(errbuf)))); 756 763 sigaction (SIGPIPE, &old_act, NULL); 757 764 SL_RETURN( countbytes, _("sh_write_select")); … … 771 778 *w_error = errno; 772 779 TPT(( 0, FIL__, __LINE__, _("msg=<select: %s>\n"), 773 sh_error_message(*w_error )));780 sh_error_message(*w_error, errbuf, sizeof(errbuf)))); 774 781 sigaction (SIGPIPE, &old_act, NULL); 775 782 SL_RETURN( countbytes, _("sh_write_select")); … … 853 860 { 854 861 unsigned long bytes; 855 char errmsg[256];856 862 857 863 SL_ENTER(_("write_port")); … … 860 866 if (*w_error != 0) 861 867 { 862 sl_strlcpy(errmsg, sh_error_message (*w_error), sizeof(errmsg));868 char errbuf[SH_ERRBUF_SIZE]; 863 869 sh_error_handle((-1), FIL__, __LINE__, *w_error, MSG_TCP_NETRP, 864 errmsg, (long) sockfd, _("write_port")); 870 sh_error_message (*w_error, errbuf, sizeof(errbuf)), 871 (long) sockfd, _("write_port")); 865 872 } 866 873 SL_RETURN( bytes, _("write_port")); … … 874 881 { 875 882 unsigned long bytes; 876 char errmsg[256];877 883 878 884 SL_ENTER(_("read_port")); … … 881 887 if (*w_error != 0) 882 888 { 883 sl_strlcpy(errmsg, sh_error_message (*w_error), sizeof(errmsg));889 char errbuf[SH_ERRBUF_SIZE]; 884 890 sh_error_handle((-1), FIL__, __LINE__, *w_error, MSG_TCP_NETRP, 885 errmsg, (long) sockfd, _("read_port")); 891 sh_error_message (*w_error, errbuf, sizeof(errbuf)), 892 (long) sockfd, _("read_port")); 886 893 } 887 894 SL_RETURN( bytes, _("read_port")); … … 1216 1223 if (err_num < 0) 1217 1224 { 1225 char expbuf[SH_ERRBUF_SIZE]; 1218 1226 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 1219 errorExplain(err_num ),1227 errorExplain(err_num, expbuf, sizeof(expbuf)), 1220 1228 _("sh_tools_makePack: cipherInit")); 1221 1229 } … … 1227 1235 if (err_num < 0) 1228 1236 { 1237 char expbuf[SH_ERRBUF_SIZE]; 1229 1238 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 1230 errorExplain(err_num ),1239 errorExplain(err_num, expbuf, sizeof(expbuf)), 1231 1240 _("sh_tools_makePack: blockEncrypt")); 1232 1241 } … … 1255 1264 int err_num; 1256 1265 int blkfac; 1266 char expbuf[SH_ERRBUF_SIZE]; 1257 1267 1258 1268 msg_size = (256 * (unsigned int)header[1] + (unsigned int)header[2]); … … 1274 1284 { 1275 1285 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 1276 errorExplain(err_num ),1286 errorExplain(err_num, expbuf, sizeof(expbuf)), 1277 1287 _("sh_tools_revertPack: cipherInit")); 1278 1288 } … … 1285 1295 { 1286 1296 sh_error_handle((-1), FIL__, __LINE__, -1, MSG_E_SUBGEN, 1287 errorExplain(err_num ),1297 errorExplain(err_num, expbuf, sizeof(expbuf)), 1288 1298 _("sh_tools_revertPack: blockDecrypt")); 1289 1299 } -
trunk/src/sh_unix.c
r131 r132 797 797 #endif 798 798 #ifdef SIGPIPE 799 #ifdef HAVE_PTHREAD 800 retry_sigaction(FIL__, __LINE__, SIGPIPE, &ignact, &oldact); 801 #else 799 802 retry_sigaction(FIL__, __LINE__, SIGPIPE, &act, &oldact); 803 #endif 800 804 #endif 801 805 #ifdef SIGALRM … … 1181 1185 1182 1186 #ifdef HAVE_INITGROUPS 1183 char * sh_unix_getUIDname (int level, uid_t uid );1187 char * sh_unix_getUIDname (int level, uid_t uid, char * out, size_t len); 1184 1188 int sh_unix_initgroups2 (uid_t in_pid, gid_t in_gid) 1185 1189 { 1186 1190 int status = -1; 1187 char * user = NULL;1191 char user[SH_MINIBUF]; 1188 1192 1189 1193 SL_ENTER(_("sh_unix_initgroups2")); 1190 1194 1191 user = sh_unix_getUIDname (SH_ERR_ERR, in_pid); 1192 if (user == NULL) 1195 if (NULL == sh_unix_getUIDname (SH_ERR_ERR, in_pid, user, sizeof(user))) 1193 1196 SL_RETURN((-1), _("sh_unix_initgroups2")); 1194 1197 status = sh_initgroups (user, in_gid); … … 1481 1484 if ((test == -1) && (errno != EINVAL)) 1482 1485 { 1486 char errbuf[SH_ERRBUF_SIZE]; 1483 1487 status = errno; 1484 1488 sh_error_handle ((-1), FIL__, __LINE__, status, MSG_W_SIG, 1485 sh_error_message (status ), sig_num);1489 sh_error_message (status, errbuf, sizeof(errbuf)), sig_num); 1486 1490 } 1487 1491 } … … 1734 1738 if ( (-1) == status ) 1735 1739 { 1740 char errbuf[SH_ERRBUF_SIZE]; 1736 1741 status = errno; 1737 1742 sh_error_handle ((-1), FIL__, __LINE__, status, MSG_W_CHDIR, 1738 sh_error_message (status ), chroot_dir);1743 sh_error_message (status, errbuf, sizeof(errbuf)), chroot_dir); 1739 1744 aud_exit(FIL__, __LINE__, EXIT_FAILURE); 1740 1745 } … … 1779 1784 { 1780 1785 int res = 0; 1781 1786 1782 1787 SL_ENTER(_("sh_unix_setnodeamon")); 1783 1788 … … 1804 1809 extern int sh_socket_open_int (); 1805 1810 #endif 1811 char errbuf[SH_ERRBUF_SIZE]; 1806 1812 1807 1813 SL_ENTER(_("sh_unix_init")); … … 1849 1855 status = errno; 1850 1856 sh_error_handle ((-1), FIL__, __LINE__, status, MSG_W_CHDIR, 1851 sh_error_message (status ), "/");1857 sh_error_message (status, errbuf, sizeof(errbuf)), "/"); 1852 1858 aud_exit(FIL__, __LINE__, EXIT_FAILURE); 1853 1859 } … … 1897 1903 status = errno; 1898 1904 sh_error_handle((-1), FIL__, __LINE__, status, MSG_E_SUBGEN, 1899 sh_error_message(status ), _("open"));1905 sh_error_message(status, errbuf, sizeof(errbuf)), _("open")); 1900 1906 aud_exit(FIL__, __LINE__, EXIT_FAILURE); 1901 1907 } … … 1909 1915 status = errno; 1910 1916 sh_error_handle((-1), FIL__, __LINE__, status, MSG_E_SUBGEN, 1911 sh_error_message(status ), _("dup"));1917 sh_error_message(status, errbuf, sizeof(errbuf)), _("dup")); 1912 1918 aud_exit(FIL__, __LINE__, EXIT_FAILURE); 1913 1919 } … … 1962 1968 status = errno; 1963 1969 sh_error_handle((-1), FIL__, __LINE__, status, MSG_E_SUBGEN, 1964 sh_error_message(status ), _("chroot"));1970 sh_error_message(status, errbuf, sizeof(errbuf)), _("chroot")); 1965 1971 aud_exit(FIL__, __LINE__, EXIT_FAILURE); 1966 1972 } … … 2095 2101 #endif 2096 2102 2097 char * sh_unix_time (time_t thetime )2103 char * sh_unix_time (time_t thetime, char * buffer, size_t len) 2098 2104 { 2099 2105 2100 2106 int status; 2101 2107 char AsciiTime[81]; /* local time */ 2102 2108 time_t time_now; 2103 2109 struct tm * time_ptr; … … 2105 2111 struct tm time_tm; 2106 2112 #endif 2107 static char AsciiTime[81]; /* local time */2108 static char RetTime[81]; /* local time */2109 2113 #ifdef SH_USE_XML 2110 2114 static char deftime[] = N_("0000-00-00T00:00:00"); /* default time */ … … 2202 2206 #endif 2203 2207 2204 if (time_now == (-1) ) 2205 SL_RETURN( _(deftime), _("sh_unix_time")); 2208 if (time_now == (-1) ) 2209 { 2210 sl_strlcpy(buffer, _(deftime), len); 2211 SL_RETURN(buffer, _("sh_unix_time")); 2212 } 2206 2213 else 2207 2214 { … … 2214 2221 if (time_ptr != NULL) 2215 2222 { 2216 status = strftime (AsciiTime, 80,2223 status = strftime (AsciiTime, sizeof(AsciiTime), 2217 2224 #ifdef SH_USE_XML 2218 2225 _("%Y-%m-%dT%H:%M:%S%%s"), … … 2222 2229 time_ptr); 2223 2230 2224 sl_snprintf(RetTime, 80, AsciiTime, t_zone(&time_now)); 2225 2226 if ( (status == 0) || (status == 80) ) 2227 SL_RETURN( _(deftime), _("sh_unix_time")); 2231 sl_snprintf(buffer, len, AsciiTime, t_zone(&time_now)); 2232 2233 if ( (status == 0) || (status == sizeof(AsciiTime)) ) 2234 { 2235 sl_strlcpy(buffer, _(deftime), len); 2236 SL_RETURN( buffer, _("sh_unix_time")); 2237 } 2228 2238 else 2229 SL_RETURN( &RetTime[0], _("sh_unix_time")); 2239 { 2240 SL_RETURN(buffer, _("sh_unix_time")); 2241 } 2230 2242 } 2231 2243 2232 2244 /* last resort 2233 2245 */ 2234 SL_RETURN( _(deftime), _("sh_unix_time")); 2246 sl_strlcpy(buffer, _(deftime), len); 2247 SL_RETURN( buffer, _("sh_unix_time")); 2235 2248 } 2236 2249 … … 2248 2261 } 2249 2262 2250 char * sh_unix_gmttime (time_t thetime )2263 char * sh_unix_gmttime (time_t thetime, char * buffer, size_t len) 2251 2264 { 2252 2265 … … 2257 2270 struct tm time_tm; 2258 2271 #endif 2259 staticchar AsciiTime[81]; /* GMT time */2272 char AsciiTime[81]; /* GMT time */ 2260 2273 #ifdef SH_USE_XML 2261 2274 static char deftime[] = N_("0000-00-00T00:00:00"); /* default time */ … … 2292 2305 time_ptr); 2293 2306 2294 if ( (status == 0) || (status == 80) ) 2295 SL_RETURN( _(deftime), _("sh_unix_gmttime"));2307 if ( (status == 0) || (status == 80) ) 2308 sl_strlcpy(buffer, _(deftime), len); 2296 2309 else 2297 SL_RETURN( &AsciiTime[0], _("sh_unix_gmttime")); 2310 sl_strlcpy(buffer, AsciiTime, len); 2311 SL_RETURN( buffer, _("sh_unix_gmttime")); 2298 2312 } 2299 2313 2300 2314 /* last resort 2301 2315 */ 2302 SL_RETURN( _(deftime), _("sh_unix_gmttime"));2303 } 2304 2305 2306 2307 char * sh_unix_getUIDdir (int level, uid_t uid )2316 sl_strlcpy(buffer, _(deftime), len); 2317 SL_RETURN( buffer, _("sh_unix_gmttime")); 2318 } 2319 2320 2321 char * sh_unix_getUIDdir (int level, uid_t uid, char * out, size_t len) 2308 2322 { 2309 2323 struct passwd * tempres; … … 2313 2327 char buffer[SH_PWBUF_SIZE]; 2314 2328 #endif 2329 char errbuf[SH_ERRBUF_SIZE]; 2315 2330 2316 2331 SL_ENTER(_("sh_unix_getUIDdir")); … … 2326 2341 if (tempres == NULL) { 2327 2342 sh_error_handle (level, FIL__, __LINE__, EINVAL, MSG_E_PWNULL, 2328 sh_error_message(status ),2343 sh_error_message(status, errbuf, sizeof(errbuf)), 2329 2344 _("getpwuid"), (long) uid, _("completely missing")); 2330 2345 SL_RETURN( NULL, _("sh_unix_getUIDdir")); … … 2332 2347 2333 2348 if (tempres->pw_dir != NULL) { 2334 SL_RETURN( tempres->pw_dir, _("sh_unix_getUIDdir")); 2349 sl_strlcpy(out, tempres->pw_dir, len); 2350 SL_RETURN( out, _("sh_unix_getUIDdir")); 2335 2351 } else { 2336 2352 sh_error_handle (level, FIL__, __LINE__, EINVAL, MSG_E_PWNULL, 2337 sh_error_message(status ),2353 sh_error_message(status, errbuf, sizeof(errbuf)), 2338 2354 _("getpwuid"), (long) uid, _("pw_dir")); 2339 2355 SL_RETURN( NULL, _("sh_unix_getUIDdir")); … … 2341 2357 } 2342 2358 2343 char * sh_unix_getUIDname (int level, uid_t uid) 2359 SH_MUTEX_STATIC(getUIDname, PTHREAD_MUTEX_INITIALIZER); 2360 2361 char * sh_unix_getUIDname (int level, uid_t uid, char * out, size_t len) 2344 2362 { 2345 2363 struct passwd * tempres; … … 2351 2369 static uid_t old_uid; 2352 2370 static char name[32] = { '\0' }; 2371 char errbuf[SH_ERRBUF_SIZE]; 2353 2372 2354 2373 SL_ENTER(_("sh_unix_getUIDname")); 2355 2374 2356 2375 if ((uid == old_uid) && (name[0] != '\0')) { 2357 SL_RETURN( name, _("sh_unix_getUIDname")); 2376 out[0] = '\0'; 2377 SH_MUTEX_LOCK_UNSAFE(getUIDname); 2378 if ((uid == old_uid) && (name[0] != '\0')) { 2379 sl_strlcpy(out, name, len); 2380 } 2381 SH_MUTEX_UNLOCK_UNSAFE(getUIDname); 2382 if (out[0] != '\0') 2383 SL_RETURN( out, _("sh_unix_getUIDname")); 2358 2384 } 2359 2385 … … 2368 2394 if (tempres == NULL) { 2369 2395 sh_error_handle (level, FIL__, __LINE__, EINVAL, MSG_E_PWNULL, 2370 sh_error_message(status ),2396 sh_error_message(status, errbuf, sizeof(errbuf)), 2371 2397 _("getpwuid"), (long) uid, _("completely missing")); 2372 2398 SL_RETURN( NULL, _("sh_unix_getUIDname")); … … 2375 2401 2376 2402 if (tempres->pw_name != NULL) { 2377 /* NEED_LOCK */2403 SH_MUTEX_LOCK_UNSAFE(getUIDname); 2378 2404 sl_strlcpy(name, tempres->pw_name, sizeof(name)); 2379 2405 old_uid = uid; 2380 /* END_LOCK */ 2381 SL_RETURN( name, _("sh_unix_getUIDname")); 2406 sl_strlcpy(out, name, len); 2407 SH_MUTEX_UNLOCK_UNSAFE(getUIDname); 2408 SL_RETURN( out, _("sh_unix_getUIDname")); 2382 2409 } else { 2383 2410 sh_error_handle (level, FIL__, __LINE__, EINVAL, MSG_E_PWNULL, 2384 sh_error_message(status ),2411 sh_error_message(status, errbuf, sizeof(errbuf)), 2385 2412 _("getpwuid"), (long) uid, _("pw_user")); 2386 2413 SL_RETURN( NULL, _("sh_unix_getUIDname")); … … 2388 2415 } 2389 2416 2390 char * sh_unix_getGIDname (int level, gid_t gid) 2417 SH_MUTEX_STATIC(getGIDname, PTHREAD_MUTEX_INITIALIZER); 2418 2419 char * sh_unix_getGIDname (int level, gid_t gid, char * out, size_t len) 2391 2420 { 2392 2421 struct group * tempres; … … 2398 2427 char buffer[SH_GRBUF_SIZE]; 2399 2428 #endif 2429 char errbuf[SH_ERRBUF_SIZE]; 2400 2430 2401 2431 … … 2403 2433 2404 2434 if ((gid == old_gid) && (name[0] != '\0')) { 2405 SL_RETURN( name, _("sh_unix_getUIDname")); 2435 out[0] = '\0'; 2436 SH_MUTEX_LOCK_UNSAFE(getGIDname); 2437 if ((gid == old_gid) && (name[0] != '\0')) { 2438 sl_strlcpy(out, name, len); 2439 } 2440 SH_MUTEX_UNLOCK_UNSAFE(getGIDname); 2441 if (out[0] != '\0') 2442 SL_RETURN( out, _("sh_unix_getGIDname")); 2406 2443 } 2407 2444 2408 2445 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 2409 2446 status = sh_getgrgid_r(gid, &grp, buffer, sizeof(buffer), &tempres); … … 2416 2453 if (tempres == NULL) { 2417 2454 sh_error_handle (level, FIL__, __LINE__, EINVAL, MSG_E_GRNULL, 2418 sh_error_message(status ),2455 sh_error_message(status, errbuf, sizeof(errbuf)), 2419 2456 _("getgrgid"), (long) gid, _("completely missing")); 2420 2457 … … 2422 2459 } 2423 2460 2461 /* FIXME: need to return caller-supplied buffer */ 2424 2462 if (tempres->gr_name != NULL) { 2425 /* NEED_LOCK */2463 SH_MUTEX_LOCK_UNSAFE(getGIDname); 2426 2464 sl_strlcpy(name, tempres->gr_name, sizeof(name)); 2427 2465 old_gid = gid; 2428 /* END_LOCK */ 2429 SL_RETURN( name, _("sh_unix_getGIDname")); 2466 sl_strlcpy(out, name, len); 2467 SH_MUTEX_UNLOCK_UNSAFE(getGIDname); 2468 SL_RETURN( out, _("sh_unix_getGIDname")); 2430 2469 } else { 2431 2470 sh_error_handle (level, FIL__, __LINE__, EINVAL, MSG_E_GRNULL, 2432 sh_error_message(status ),2471 sh_error_message(status, errbuf, sizeof(errbuf)), 2433 2472 _("getgrgid"), (long) gid, _("gr_name")); 2434 2473 SL_RETURN( NULL, _("sh_unix_getGIDname")); … … 2440 2479 char * p; 2441 2480 uid_t seuid, sruid; 2481 char user[USER_MAX]; 2482 char dir[SH_PATHBUF]; 2442 2483 2443 2484 SL_ENTER(_("sh_unix_getUser")); … … 2447 2488 sh.effective.uid = seuid; 2448 2489 2449 p = sh_unix_getUIDdir (SH_ERR_ERR, seuid );2490 p = sh_unix_getUIDdir (SH_ERR_ERR, seuid, dir, sizeof(dir)); 2450 2491 2451 2492 if (p == NULL) … … 2466 2507 sh.real.uid = sruid; 2467 2508 2468 p = sh_unix_getUIDname (SH_ERR_ERR, sruid );2509 p = sh_unix_getUIDname (SH_ERR_ERR, sruid, user, sizeof(user)); 2469 2510 if (p == NULL) 2470 2511 SL_RETURN((-1), _("sh_unix_getUser")); … … 2480 2521 } 2481 2522 2482 p = sh_unix_getUIDdir (SH_ERR_ERR, sruid );2523 p = sh_unix_getUIDdir (SH_ERR_ERR, sruid, dir, sizeof(dir)); 2483 2524 2484 2525 if (p == NULL) … … 3270 3311 { 3271 3312 if (S_FALSE == sh_ignore_chk_del(theFile->fullpath)) { 3313 char errbuf[SH_ERRBUF_SIZE]; 3272 3314 tmp2 = sh_util_safe_name (theFile->fullpath); 3273 3315 sh_error_handle (level, FIL__, __LINE__, stat_return, MSG_FI_LSTAT, 3274 sh_error_message (stat_return), tmp2); 3316 sh_error_message (stat_return, errbuf, sizeof(errbuf)), 3317 tmp2); 3275 3318 SH_FREE(tmp2); 3276 3319 } … … 3465 3508 */ 3466 3509 3467 if ( (name = sh_unix_getGIDname(SH_ERR_ALL, 3468 buf.st_gid)) != NULL) { 3469 sl_strlcpy (theFile->c_group, name, GROUP_MAX+1); 3470 } else { 3510 if (NULL == sh_unix_getGIDname(SH_ERR_ALL, buf.st_gid, theFile->c_group, GROUP_MAX+1)) { 3471 3511 3472 3512 tmp2 = sh_util_safe_name (theFile->fullpath); … … 3489 3529 3490 3530 3491 if ( (name = sh_unix_getUIDname(SH_ERR_ALL, 3492 buf.st_uid)) != NULL) { 3493 sl_strlcpy (theFile->c_owner, name, USER_MAX+1); 3494 } else { 3531 if (NULL == sh_unix_getUIDname(SH_ERR_ALL, buf.st_uid, theFile->c_owner, USER_MAX+)) { 3495 3532 3496 3533 tmp2 = sh_util_safe_name (theFile->fullpath); … … 3518 3555 tmp2 = sh_util_safe_name ((filename == NULL) ? 3519 3556 theFile->fullpath : filename); 3520 sl_strlcpy(timestr, sh_unix_time(theFile->mtime), 81);3557 (void) sh_unix_time(theFile->mtime, timestr, sizeof(timestring)); 3521 3558 sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_FI_LIST, 3522 3559 theFile->c_mode, … … 3547 3584 if (linksize < 0) 3548 3585 { 3586 char errbuf[SH_ERRBUF_SIZE]; 3549 3587 linksize = errno; 3550 3588 tmp2 = sh_util_safe_name (theFile->fullpath); 3551 3589 sh_error_handle (level, FIL__, __LINE__, linksize, MSG_FI_RDLNK, 3552 sh_error_message (linksize ), tmp2);3590 sh_error_message (linksize, errbuf, sizeof(errbuf)), tmp2); 3553 3591 SH_FREE(tmp2); 3554 3592 SH_FREE(linknamebuf); … … 3598 3636 if (stat_return != ENOENT) 3599 3637 { 3638 char errbuf[SH_ERRBUF_SIZE]; 3600 3639 sh_error_handle (level, FIL__, __LINE__, stat_return, 3601 3640 MSG_FI_LSTAT, 3602 sh_error_message (stat_return), tmp2); 3641 sh_error_message (stat_return,errbuf, sizeof(errbuf)), 3642 tmp2); 3603 3643 } 3604 3644 else … … 3873 3913 else if (flag != NULL) 3874 3914 { 3915 char errbuf[SH_ERRBUF_SIZE]; 3875 3916 error = errno; 3876 3917 sh_error_handle ((-1), FIL__, __LINE__, error, MSG_E_UNLNK, 3877 sh_error_message(error), lockfile); 3918 sh_error_message(error, errbuf, sizeof(errbuf)), 3919 lockfile); 3878 3920 SL_RETURN((-1),_("sh_unix_unlock")); 3879 3921 } … … 4211 4253 { 4212 4254 #ifdef TEST_MLOCK 4213 fprintf(stderr, "mlock: error: %s\n", sh_error_message(errno)); 4255 char errbuf[SH_ERRBUF_SIZE]; 4256 fprintf(stderr, "mlock: error: %s\n", 4257 sh_error_message(errno, errbuf, sizeof(errbuf))); 4214 4258 #endif 4215 4259 SH_FREE(page_list); -
trunk/src/sh_utmp.c
r68 r132 799 799 ) { 800 800 status = sh_utmp_login_a(user->name); 801 (void) s l_strlcpy(ttt, sh_unix_time (user->time), TIM_MAX);801 (void) sh_unix_time (user->time, ttt, TIM_MAX); 802 802 sh_error_handle( ShUtmpLoginSolo, FIL__, __LINE__, 0, 803 803 #if defined(HAVE_UTHOST) && defined(HAVE_UTADDR) … … 823 823 { 824 824 status = sh_utmp_login_a(user->name); 825 (void) s l_strlcpy(ttt, sh_unix_time (user->time), TIM_MAX);825 (void) sh_unix_time (user->time, ttt, TIM_MAX); 826 826 sh_error_handle( ShUtmpLoginMulti, FIL__, __LINE__, 0, 827 827 #if defined(HAVE_UTHOST) && defined(HAVE_UTADDR) … … 858 858 { 859 859 status = sh_utmp_login_r(user->name); 860 /* sl_strlcpy(ttt, sh_unix_time (user->time), TIM_MAX); */ 861 (void) sl_strlcpy(ttt, sh_unix_time (ut->ut_time), TIM_MAX); 860 (void) sh_unix_time (ut->ut_time, ttt, TIM_MAX); 862 861 sh_error_handle( ShUtmpLogout, FIL__, __LINE__, 0, 863 862 #if defined(HAVE_UTHOST) && defined(HAVE_UTADDR) … … 889 888 { 890 889 (void) sl_strlcpy(terminated_line, ut->ut_line, UT_HOSTSIZE); 891 (void) s l_strlcpy(ttt, sh_unix_time (ut->ut_time), TIM_MAX);890 (void) sh_unix_time (ut->ut_time, ttt, TIM_MAX); 892 891 sh_error_handle( ShUtmpLogout, FIL__, __LINE__, 0, 893 892 MSG_UT_LG3C, … … 920 919 userlist = user; 921 920 922 sl_strlcpy(ttt, sh_unix_time (user->time), TIM_MAX);921 (void) sh_unix_time (user->time, ttt, TIM_MAX); 923 922 924 923 … … 946 945 else /* probably a logout */ 947 946 { 948 sl_strlcpy(ttt, sh_unix_time (ut->ut_time), TIM_MAX); 949 /* sl_strlcpy(ttt, sh_unix_time (user->time), TIM_MAX); */ 947 (void) sh_unix_time (ut->ut_time, ttt, TIM_MAX); 950 948 951 949 sh_error_handle( ShUtmpLogout, FIL__, __LINE__, 0,
Note:
See TracChangeset
for help on using the changeset viewer.