Changeset 149 for trunk/include


Ignore:
Timestamp:
Jan 7, 2008, 8:52:13 PM (17 years ago)
Author:
katerina
Message:

Make sh_hash.c thread-safe, remove plenty of tiny allocations, improve sh_mem_dump, modify port check to run as thread, and fix unsetting of sh_thread_pause_flag (was too early).

Location:
trunk/include
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/samhain.h

    r143 r149  
    4848 */
    4949#define SOCKPASS_MAX 14
    50 #define USER_MAX  20
    51 #define GROUP_MAX 20
    52 #define TIM_MAX   32
    53 
     50#define USER_MAX     20
     51#define GROUP_MAX    20
     52#define TIM_MAX      32
     53
     54#define CMODE_SIZE   11
     55
     56#define ATTRBUF_SIZE 16
     57#define ATTRBUF_USED 12
    5458
    5559/* The number of bytes in a key, 
     
    159163#define SET_SH_FFLAG_SUIDCHK(a)     ((a) |= SH_FFLAG_SUIDCHK)
    160164#define CLEAR_SH_FFLAG_SUIDCHK(a)   ((a) &= ~SH_FFLAG_SUIDCHK)
    161 
    162165
    163166
     
    340343
    341344#if defined(__GNUC__) && (__GNUC__ >= 4)
    342 #define SH_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
    343 #else
    344 #define SH_GNUC_NULL_TERMINATED
    345 #endif
     345#define SH_GNUC_SENTINEL __attribute__((__sentinel__))
     346#else
     347#define SH_GNUC_SENTINEL
     348#endif
     349
     350#if defined(__GNUC__) && (__GNUC__ >= 3)
     351#undef  SH_GNUC_PURE
     352#define SH_GNUC_PURE     __attribute__((pure))
     353#undef  SH_GNUC_CONST
     354#define SH_GNUC_CONST    __attribute__((const))
     355#undef  SH_GNUC_NORETURN
     356#define SH_GNUC_NORETURN __attribute__((noreturn))
     357#undef  SH_GNUC_MALLOC
     358#define SH_GNUC_MALLOC   __attribute__((malloc))
     359#else
     360#undef  SH_GNUC_PURE
     361#define SH_GNUC_PURE
     362#undef  SH_GNUC_CONST
     363#define SH_GNUC_CONST
     364#undef  SH_GNUC_NORETURN
     365#define SH_GNUC_NORETURN
     366#undef  SH_GNUC_MALLOC
     367#define SH_GNUC_MALLOC
     368#endif
     369
    346370
    347371/* The semantics of the built-in are that it is expected that expr == const
  • trunk/include/sh_mem.h

    r1 r149  
    3838#else
    3939
     40#if defined(__GNUC__) && (__GNUC__ >= 3)
     41#undef  SH_GNUC_MALLOC
     42#define SH_GNUC_MALLOC   __attribute__((malloc))
     43#else
     44#undef  SH_GNUC_MALLOC
     45#define SH_GNUC_MALLOC
     46#endif
    4047
    4148void   sh_mem_free (/*@only@*//*@out@*//*@null@*/ void * a);
    42 /*@only@*//*@notnull@*/void * sh_mem_malloc (size_t size);
     49/*@only@*//*@notnull@*/void * sh_mem_malloc (size_t size) SH_GNUC_MALLOC;
    4350
    4451#define SH_FREE(a)   sh_mem_free(a)
  • trunk/include/sh_suidchk.h

    r140 r149  
    66
    77#ifdef SH_USE_SUIDCHK
    8 int sh_suidchk_init  (struct mod_type * arg);
    9 int sh_suidchk_timer (time_t tcurrent);
    10 int sh_suidchk_check (void);
    11 int sh_suidchk_end   (void);
    12 int sh_suidchk_free_schedule (void);
     8int sh_suidchk_init   (struct mod_type * arg);
     9int sh_suidchk_timer  (time_t tcurrent);
     10int sh_suidchk_check  (void);
     11int sh_suidchk_end    (void);
     12int sh_suidchk_reconf (void);
    1313
    1414int sh_suidchk_set_activate   (const char * c);
  • trunk/include/sh_unix.h

    r132 r149  
    120120#if defined(__linux__) || defined(HAVE_STAT_FLAGS)
    121121  unsigned long    attributes;
    122   char             c_attributes[16];
    123 #endif
    124   char             c_mode[11];
     122  char             c_attributes[ATTRBUF_SIZE];
     123#endif
     124  char             c_mode[CMODE_SIZE];
    125125  uid_t            owner;
    126126  char             c_owner[USER_MAX+2];
  • trunk/include/sh_utils.h

    r138 r149  
    6464/* returns allocated memory
    6565 */
    66 char * sh_util_strdup (const char * str);
     66char * sh_util_strdup (const char * str) SH_GNUC_MALLOC;
    6767
    6868/* returns allocated memory
    6969 */
    70 char * sh_util_strdup_l (const char * str, size_t len);
     70char * sh_util_strdup_l (const char * str, size_t len) SH_GNUC_MALLOC;
    7171
    7272/* returns pointer within str
     
    119119/* read a hexchar, return int value (0-15)
    120120 */
    121 int sh_util_hexchar( char c );
     121int sh_util_hexchar( char c ) SH_GNUC_CONST;
    122122
    123123/* change verifier
     
    159159 * Argument list must be NULL terminated.
    160160 */
    161 char * sh_util_strconcat (const char * arg1, ...) SH_GNUC_NULL_TERMINATED;
     161char * sh_util_strconcat (const char * arg1, ...) SH_GNUC_MALLOC SH_GNUC_SENTINEL;
    162162
    163163/* check if string is numeric only
    164164 */
    165 int sh_util_isnum (char *str);
     165int sh_util_isnum (const char *str) SH_GNUC_PURE;
    166166
    167167/* init a key w/random string
     
    176176/* returns freshly allocated memory, return value should be free'd
    177177 */
    178 char * sh_util_safe_name (const char * name);
     178char * sh_util_safe_name (const char * name) SH_GNUC_MALLOC SH_GNUC_PURE;
    179179
    180180/* check max size of printf result string
  • trunk/include/sh_utmp.h

    r140 r149  
    66
    77#ifdef SH_USE_UTMP
    8 int sh_utmp_init  (struct mod_type * arg);
    9 int sh_utmp_timer (time_t tcurrent);
    10 int sh_utmp_check (void);
    11 int sh_utmp_end (void);
    12 int sh_utmp_null (void);
     8int sh_utmp_init   (struct mod_type * arg);
     9int sh_utmp_timer  (time_t tcurrent);
     10int sh_utmp_check  (void);
     11int sh_utmp_end    (void);
     12int sh_utmp_reconf (void);
    1313
    1414int sh_utmp_set_login_activate (const char * c);
  • trunk/include/slib.h

    r138 r149  
    6363#define SH_PWBUF_SIZE  4096
    6464
     65
     66#if defined(__GNUC__) && (__GNUC__ >= 3)
     67#undef  SL_GNUC_CONST
     68#define SL_GNUC_CONST   __attribute__((const))
     69#else
     70#undef  SH_GNUC_CONST
     71#define SH_GNUC_CONST
     72#endif
    6573
    6674/*
     
    405413  /* Overflow tests
    406414   */
    407   int sl_ok_muli (int a, int b);
    408   int sl_ok_divi (int a, int b);
    409   int sl_ok_addi (int a, int b);
    410   int sl_ok_subi (int a, int b);
    411 
    412   int sl_ok_muls (size_t a, size_t b);
    413   int sl_ok_adds (size_t a, size_t b);
     415  int sl_ok_muli (int a, int b) SL_GNUC_CONST;
     416  int sl_ok_divi (int a, int b) SL_GNUC_CONST;
     417  int sl_ok_addi (int a, int b) SL_GNUC_CONST;
     418  int sl_ok_subi (int a, int b) SL_GNUC_CONST;
     419
     420  int sl_ok_muls (size_t a, size_t b) SL_GNUC_CONST;
     421  int sl_ok_adds (size_t a, size_t b) SL_GNUC_CONST;
    414422
    415423
Note: See TracChangeset for help on using the changeset viewer.