Changeset 22 for trunk/src/samhain.c


Ignore:
Timestamp:
Feb 23, 2006, 12:03:58 AM (19 years ago)
Author:
rainer
Message:

Minor code revisions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/samhain.c

    r20 r22  
    382382   */
    383383  (void) sl_strlcpy (sh.host.name,  _("localhost"),  SH_MINIBUF);
    384   sh.host.system[0]     = '\0';
     384  sh.host.system[0]     = '\0'; /* flawfinder: ignore *//* ff bug */
    385385  sh.host.release[0]    = '\0';
    386386  sh.host.machine[0]    = '\0';
     
    582582  skey->mailkey_old[0]  = '\0';
    583583  skey->mailkey_new[0]  = '\0';
    584   skey->crypt[0]        = '\0';
     584  skey->crypt[0]        = '\0'; /* flawfinder: ignore *//* ff bug */
    585585  skey->session[0]      = '\0';
    586586  skey->vernam[0]       = '\0';
     
    725725  char         exef[128];
    726726
     727  if (!pidlist)
     728    return NULL;
     729
    727730  for (i = 0; i < 65535; ++i) pidlist[i] = 0;
    728731  i = 0;
    729732
    730733  if (0 != stat(SH_INSTALL_PATH, &buf))
    731     return NULL;
     734    {
     735      free(pidlist);
     736      return NULL;
     737    }
    732738
    733739  ino = (long) buf.st_ino;
    734740   
    735741  if (NULL == (dp = opendir("/proc")))
    736     return NULL;
     742    {
     743      free(pidlist);
     744      return NULL;
     745    }
    737746  while (NULL != (d = readdir(dp)) && i < 65535)
    738747    {
     
    860869
    861870
    862   fullpath = malloc(strlen(SH_INSTALL_PATH)+1);
     871  fullpath = strdup (SH_INSTALL_PATH);
    863872  if (fullpath == NULL)
    864     { perror(_("malloc")); exit (1); }
    865   else
    866     strcpy(fullpath, SH_INSTALL_PATH);                 /* known to fit  */
    867 
    868   argp[0] = malloc(strlen(SH_INSTALL_PATH)+1);
     873    { perror(_("strdup")); exit (1); }
     874
     875  argp[0]  = strdup (SH_INSTALL_PATH);
    869876  if (argp[0] == NULL)
    870     { perror(_("malloc")); exit (1); }
    871   else
    872     strcpy(argp[0], SH_INSTALL_PATH);                  /* known to fit  */
    873 
     877    { perror(_("strdup")); exit (1); }
    874878
    875879  for (times = 1; times < 32; ++times)  argp[times] = NULL;
     
    879883  for (times = 2; times < res; ++times) 
    880884    {
    881       argp[times-1] = malloc(strlen(argv[times])+1);
     885      argp[times-1] = strdup (argv[times]);
    882886      if (argp[times-1] == NULL)
    883         { perror(_("malloc")); exit (1); }
    884       else
    885         strcpy(argp[times-1], argv[times]);              /* known to fit  */
     887        { perror(_("strdup")); exit (1); }
    886888    }
    887889
     
    903905            _exit(4);
    904906          }
    905         (void) execv(fullpath, argp);
     907        (void) execv(fullpath, argp); /* flawfinder: ignore *//* wtf? */
    906908        if (errno == EPERM)
    907909          _exit(4);
     
    941943      pidlist = procdirSamhain ();
    942944      if (pid == 0 && NULL == pidlist) /* pid file not found */
    943         return (0);
     945        {
     946          free(fullpath);
     947          return (0);
     948        }
    944949         
    945950      status = 0;
     
    956961            }
    957962        }
     963      free(fullpath);
    958964      if (status == 7)
    959965        return 0;
     
    992998        }
    993999    }
    994 
     1000  free(fullpath); /* silence smatch false positive */
    9951001  exit (1); /* no exit handler installed yet */
    9961002  /*@notreached@*/
     
    10221028/* Add a new schedule to the linked list of schedules
    10231029 */
    1024 static sh_schedule_t * sh_set_schedule_int (char * str,
     1030static sh_schedule_t * sh_set_schedule_int (const char * str,
    10251031                                            sh_schedule_t * FileSchedIn,
    10261032                                            /*@out@*/ int * status)
     
    10521058/* Add a new schedule to the linked list FileSchedOne
    10531059 */
    1054 int sh_set_schedule_one (char * str)
     1060int sh_set_schedule_one (const char * str)
    10551061{
    10561062  int status;
     
    10611067/* Add a new schedule to the linked list FileSchedTwo
    10621068 */
    1063 int sh_set_schedule_two (char * str)
     1069int sh_set_schedule_two (const char * str)
    10641070{
    10651071  int status;
     
    12141220  /* Save the timezone.
    12151221   */
    1216   if ((tzptr = getenv("TZ")) != NULL)
     1222  if (NULL != (tzptr = getenv("TZ"))) /* flawfinder: ignore */
    12171223    {
    12181224      tzlen       = strlen(tzptr);
    1219        sh.timezone = malloc (tzlen + 1);
    1220       if (sh.timezone != NULL)
    1221          (void) sl_strlcpy (sh.timezone, tzptr, tzlen + 1);
     1225      if (tzlen < 1024)
     1226        {
     1227          sh.timezone = malloc (tzlen + 1);
     1228          if (sh.timezone != NULL)
     1229            (void) sl_strlcpy (sh.timezone, tzptr, tzlen + 1);
     1230        }
     1231      else
     1232        sh.timezone = NULL;
    12221233    }
    12231234  else
Note: See TracChangeset for help on using the changeset viewer.