Changeset 257 for trunk/src


Ignore:
Timestamp:
Oct 31, 2009, 8:53:58 PM (15 years ago)
Author:
katerina
Message:

Fix for issues with debug code and testsuite (tickets #174, #175).

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_cat.c

    r206 r257  
    260260  { MSG_MSTAMP,      SH_ERR_STAMP,   STAMP, N_("msg=\"Memory used:  max.=%lu, current=%lu\"")},
    261261  { MSG_MSTAMP2,     SH_ERR_STAMP,   STAMP, N_("msg=\"Blocks: %d allocated, %d freed, %d maximum\"")},
    262   { MSG_E_MNULL,     SH_ERR_ERR,     ERR,   N_("msg=\"Dereferenced NULL pointer\" source_file=\"%s\" source_line=\"%d\"")},
     262  { MSG_E_MNULL,     SH_ERR_ERR,     ERR,   N_("msg=\"Dereferenced NULL pointer allocated in %s, line %d\" source_file=\"%s\" source_line=\"%d\"")},
    263263  { MSG_E_MMEM,      SH_ERR_ERR,     ERR,   N_("msg=\"Out of memory\" source_file=\"%s\" source_line=\"%d\"")},
    264264  { MSG_E_MREC,      SH_ERR_ERR,     ERR,   N_("msg=\"Free() on unrecorded block\" source_file=\"%s\" source_line=\"%d\"")},
  • trunk/src/sh_log_check.c

    r252 r257  
    811811int sh_log_check_init (struct mod_type * arg)
    812812{
     813#if !defined(HAVE_PTHREAD)
     814  (void) arg;
     815#endif
     816
    813817  if (ShLogmonActive == S_FALSE)
    814818    return SH_MOD_FAILED;
  • trunk/src/sh_mem.c

    r256 r257  
    112112#endif
    113113
     114static void ** sh_mem_merr_1;
     115
    114116void sh_mem_stat ()
    115117{
    116118  memlist_t   * this;
    117 
     119  memlist_t   * merrlist = NULL;
    118120
    119121  SL_ENTER(_("sh_mem_stat"));
    120122
     123  sh_mem_merr_1 = (void **) &merrlist;
    121124
    122125  if (Alloc_Count == Free_Count)
     
    139142  while (this != NULL)
    140143    {
     144      memlist_t   * merr = (memlist_t *) malloc (sizeof(memlist_t));
     145
     146      memcpy(merr, this, sizeof(memlist_t));
     147      merr->next = merrlist;
     148      merrlist   = merr;
     149
     150      this = this->next;
     151    }
     152
     153  SH_MUTEX_RECURSIVE_UNLOCK(mutex_mem);
     154
     155  while (merrlist != NULL)
     156    {
     157      memlist_t   * tmp = merrlist;
     158      merrlist = merrlist->next;
     159     
    141160      sh_error_handle (SH_ERR_WARN, FIL__, __LINE__, 0, MSG_E_NOTFREE,
    142                        this->size, this->file, this->line);
    143       this = this->next;
    144     }
    145 
    146   SH_MUTEX_RECURSIVE_UNLOCK(mutex_mem);
     161                       tmp->size, tmp->file, tmp->line);
     162      free(tmp);
     163    }
     164
    147165  SL_RET0(_("sh_mem_stat"));
    148166}
    149167
     168static void ** sh_mem_merr_2;
     169
    150170void sh_mem_check ()
    151171{
    152172  memlist_t * this;
     173  memlist_t * merrlist = NULL;
     174  memlist_t * merr;
    153175  long        nerr = 0;
    154176
    155177  SL_ENTER(_("sh_mem_check"));
     178
     179  sh_mem_merr_2 = (void **) &merrlist;
    156180
    157181  sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_MSTAMP,
     
    167191      if ( this->address == NULL )
    168192        {
    169           sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MNULL);
     193          merr = (memlist_t *) malloc (sizeof(memlist_t));
     194
     195          memcpy(merr, this, sizeof(memlist_t));
     196          merr->size = 2;
     197
     198          merr->next = merrlist;
     199          merrlist   = merr;
    170200          ++nerr;
    171201        }
     
    174204          if ( this->address[this->size]        != CHECKBYTE )
    175205            {
    176               sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MOVER,
    177                                this->file, this->line, FIL__, __LINE__);
     206              merr = (memlist_t *) malloc (sizeof(memlist_t));
     207             
     208              memcpy(merr, this, sizeof(memlist_t));
     209              merr->size = 1;
     210             
     211              merr->next = merrlist;
     212              merrlist   = merr;
    178213              ++nerr;
    179214            }
    180215          if ( this->real_address[SH_MEMMULT-1] != CHECKBYTE )
    181216            {
    182               sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MUNDER,
    183                                this->file, this->line, FIL__, __LINE__);
     217              merr = (memlist_t *) malloc (sizeof(memlist_t));
     218             
     219              memcpy(merr, this, sizeof(memlist_t));
     220              merr->size = 0;
     221             
     222              merr->next = merrlist;
     223              merrlist   = merr;
    184224              ++nerr;
    185225            }
     
    190230
    191231  SH_MUTEX_RECURSIVE_UNLOCK(mutex_mem);
     232
     233  while (merrlist != NULL)
     234    {
     235      memlist_t   * tmp = merrlist;
     236      merrlist = merrlist->next;
     237     
     238      if (tmp->size == 2)
     239          sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MNULL,
     240                           tmp->file, tmp->line, FIL__, __LINE__);
     241      if (tmp->size == 1)
     242          sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MOVER,
     243                           tmp->file, tmp->line, FIL__, __LINE__);
     244      else
     245          sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MUNDER,
     246                           tmp->file, tmp->line, FIL__, __LINE__);
     247      free(tmp);
     248    }
     249
    192250  SL_RET0(_("sh_mem_check"));
    193251}
     
    203261  SH_MUTEX_RECURSIVE_INIT(mutex_mem);
    204262  SH_MUTEX_RECURSIVE_LOCK(mutex_mem);
     263
    205264  the_realAddress = malloc(size + 2 * SH_MEMMULT);
    206265 
     
    258317
    259318static void ** sh_mem_dummy_a;
     319static void ** sh_mem_merr_3;
    260320
    261321void sh_mem_free (void * aa, char * file, int line)
     
    263323  memlist_t * this;
    264324  memlist_t * before;
     325  memlist_t * merr;
     326  memlist_t * merrlist = NULL;
    265327  unsigned long        size   = 0;
    266328  void      * a;
     
    271333  a      = aa;
    272334  sh_mem_dummy_a = &a;
     335  sh_mem_merr_3  = (void **) &merrlist;
    273336
    274337
     
    276339    {
    277340      sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MNULL,
    278                        file, line);
     341                       file, line, FIL__, __LINE__);
    279342      SL_RET0(_("sh_mem_free"));
    280343    }
     
    307370      if ( this->address[this->size]        != CHECKBYTE )
    308371        {
    309           sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MOVER,
    310                            this->file, this->line, file, line);
     372          merr = (memlist_t *) malloc (sizeof(memlist_t));
     373
     374          memcpy(merr, this, sizeof(memlist_t));
     375          merr->size = 1;
     376
     377          merr->next = merrlist;
     378          merrlist = merr;
    311379        }
     380
    312381      if ( this->real_address[SH_MEMMULT-1] != CHECKBYTE )
    313         sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MUNDER,
    314                          this->file, this->line, file, line);
     382        {
     383          merr = (memlist_t *) malloc (sizeof(memlist_t));
     384
     385          memcpy(merr, this, sizeof(memlist_t));
     386          merr->size = 0;
     387
     388          merr->next = merrlist;
     389          merrlist = merr;
     390        }
    315391
    316392      size = this->size;
     
    325401  if (this)
    326402    free(this);
     403
    327404  ++Free_Count;
    328405  --Now_Alloc_Count;
     
    332409  ; /* label at end of compound statement */
    333410  SH_MUTEX_RECURSIVE_UNLOCK(mutex_mem);
     411
     412  while (merrlist != NULL)
     413    {
     414      memlist_t   * tmp = merrlist;
     415      merrlist = merrlist->next;
     416     
     417      if (tmp->size == 1)
     418          sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MOVER,
     419                           tmp->file, tmp->line, file, line);
     420      else
     421          sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MUNDER,
     422                           tmp->file, tmp->line, file, line);
     423      free(tmp);
     424    }
     425
    334426  if (flag != 0)
    335427    sh_error_handle ((-1), FIL__, __LINE__, 0, MSG_E_MREC,
    336428                     file, line);
     429
    337430  SL_RET0(_("sh_mem_free"));
    338431}
  • trunk/src/sh_portcheck.c

    r253 r257  
    16181618  if (sh_portchk_active != S_FALSE)
    16191619    {
    1620 #ifdef SL_DEBUG
    1621       sh_error_handle(SH_ERR_NOTICE, FIL__, __LINE__, 0, MSG_E_SUBGEN,
    1622                       _("Checking for open ports"),
    1623                       _("sh_portchk_check"));
    1624 #else
    16251620      sh_error_handle(SH_ERR_INFO, FIL__, __LINE__, 0, MSG_E_SUBGEN,
    16261621                      _("Checking for open ports"),
    16271622                      _("sh_portchk_check"));
    1628 #endif
    16291623
    16301624      sh_portchk_reset_lists();
  • trunk/src/sh_processcheck.c

    r253 r257  
    13601360    {
    13611361      SH_MUTEX_LOCK(mutex_thread_nolog);
    1362 #ifdef SL_DEBUG
    1363       sh_error_handle(SH_ERR_NOTICE, FIL__, __LINE__, 0, MSG_PCK_CHECK,
    1364                       (unsigned long) sh_prochk_minpid,
    1365                       (unsigned long) (sh_prochk_maxpid-1));
    1366 #else
    13671362      sh_error_handle((-1), FIL__, __LINE__, 0, MSG_PCK_CHECK,
    13681363                      (unsigned long) sh_prochk_minpid,
    13691364                      (unsigned long) (sh_prochk_maxpid-1));
    1370 #endif
    13711365      SH_MUTEX_UNLOCK(mutex_thread_nolog);
    13721366
  • trunk/src/sh_suidchk.c

    r253 r257  
    14561456
    14571457  SH_MUTEX_LOCK(mutex_thread_nolog);
    1458   sh_error_handle (SH_ERR_NOTICE, FIL__, __LINE__, EINVAL, MSG_E_SUBGEN,
     1458  sh_error_handle (SH_ERR_INFO, FIL__, __LINE__, EINVAL, MSG_E_SUBGEN,
    14591459                   _("Checking for SUID programs"),
    1460                    _("suidchk_check") );
     1460                   _("sh_suidchk_check") );
    14611461  SH_MUTEX_UNLOCK(mutex_thread_nolog);
    14621462
Note: See TracChangeset for help on using the changeset viewer.