Changeset 579 for trunk/src


Ignore:
Timestamp:
May 14, 2023, 10:08:17 PM (16 months ago)
Author:
katerina
Message:

Fix for ticket #467 (memleak).

Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/samhain.c

    r550 r579  
    777777  sh_hash_hashdelete();
    778778  sh_files_hle_reg (NULL);
     779  (void) sh_ignore_clean ();
    779780  /*
    780781   * Only flush on exit if running as deamon.
  • trunk/src/sh_dbIO.c

    r578 r579  
    14151415    lpath = ll;
    14161416  else
     1417    /* cppcheck-suppress uninitvar */
    14171418    lpath = linkpath;
    14181419
  • trunk/src/sh_files.c

    r565 r579  
    23152315            {
    23162316              ++theDir->NumDirs;
     2317#if defined(SH_USE_SCANDIR)
     2318              free(entryList[entry]); /* scandir() mallocs entries */
     2319#endif
    23172320              continue;
    23182321            }
     
    23202323            {
    23212324              ++theDir->NumDirs;
     2325#if defined(SH_USE_SCANDIR)
     2326              free(entryList[entry]); /* scandir() mallocs entries */
     2327#endif
    23222328              continue;
    23232329            }
  • trunk/src/sh_mem.c

    r516 r579  
    7777#endif
    7878
    79 /* define MEM_LOG to an absolute filename to enable this */
     79/* define MEM_LOG to enable this */
     80/* #define MEM_LOG 1 */
    8081#ifdef MEM_LOG
    8182void sh_mem_dump ()
     
    8384  memlist_t   * this = memlist;
    8485  FILE * fd;
    85 
     86  static unsigned int nr = 0;
     87  char filename[256];
     88
     89  snprintf(filename, sizeof(filename), "sh_mem_dump.%04u.%lu", nr, (unsigned long) sh.pid);
     90 
    8691  SH_MUTEX_RECURSIVE_INIT(mutex_mem);
    8792  SH_MUTEX_RECURSIVE_LOCK(mutex_mem);
    8893
    89   fd = fopen(MEM_LOG, "w");
     94  fd = fopen(filename, "w");
    9095  if (!fd)
    9196    {
    92       perror(MEM_LOG);
     97      perror(filename);
    9398      _exit(EXIT_FAILURE);
    9499    }
     
    103108
    104109  SH_MUTEX_RECURSIVE_UNLOCK(mutex_mem);
    105   _exit(EXIT_SUCCESS);
     110  ++nr;
     111  /* _exit(EXIT_SUCCESS); */
     112  return;
    106113}
    107114#else
  • trunk/src/sh_sig.c

    r571 r579  
    16951695#elif defined(WITH_SIGNIFY)
    16961696  return sh_signify_check_signature (file, what);
     1697#else
     1698  return -1;
    16971699#endif
    16981700}
     
    17041706#elif defined(WITH_SIGNIFY)
    17051707  return sh_signify_extract_signed(fd, SIG_DATASIG);
     1708#else
     1709  return -1;
    17061710#endif
    17071711}
     
    17131717#elif defined(WITH_SIGNIFY)
    17141718  return sh_signify_extract_signed(fd, SIG_DATAONLY);
     1719#else
     1720  return -1;
    17151721#endif
    17161722}
     
    17221728#elif defined(WITH_SIGNIFY)
    17231729  return sh_signify_msg_start(line);
     1730#else
     1731  return -1;
    17241732#endif
    17251733}
     
    17311739#elif defined(WITH_SIGNIFY)
    17321740  return sh_signify_msg_startdata(line);
     1741#else
     1742  return -1;
    17331743#endif
    17341744}
     
    17401750#elif defined(WITH_SIGNIFY)
    17411751  return sh_signify_msg_end(line);
     1752#else
     1753  return -1;
    17421754#endif
    17431755}
     
    17491761#elif defined(WITH_SIGNIFY)
    17501762  return sh_signify_data_end(line);
     1763#else
     1764  return -1;
    17511765#endif
    17521766}
  • trunk/src/sh_unix.c

    r570 r579  
    36033603              }
    36043604            }
    3605           SH_FREE(rotated_file);
    3606         }
     3605        }
     3606      if (rotated_file) {
     3607        SH_FREE(rotated_file);
     3608      }
    36073609    }
    36083610  return retval;
     
    48724874  if (0 == retry_lstat(FIL__, __LINE__, path, &buf))
    48734875    SL_RETURN( S_TRUE,   _("sh_unix_file_exists"));
    4874   else
    4875     SL_RETURN( S_FALSE,  _("sh_unix_file_exists"));
     4876
     4877  SL_RETURN( S_FALSE,  _("sh_unix_file_exists"));
    48764878}
    48774879
     
    48884890  if (retry_fstat(FIL__, __LINE__, fd, &buf) == -1)
    48894891    SL_RETURN( (-1), _("sh_unix_device_readable"));
    4890   else if ( S_ISCHR(buf.st_mode) &&  0 != (S_IROTH & buf.st_mode) )
     4892  if ( S_ISCHR(buf.st_mode) &&  0 != (S_IROTH & buf.st_mode) )
    48914893    SL_RETURN( (0), _("sh_unix_device_readable"));
    4892   else
    4893     SL_RETURN( (-1), _("sh_unix_device_readable"));
     4894
     4895  SL_RETURN( (-1), _("sh_unix_device_readable"));
    48944896}
    48954897
Note: See TracChangeset for help on using the changeset viewer.