Changeset 131 for trunk/src/samhain.c


Ignore:
Timestamp:
Oct 22, 2007, 11:19:15 PM (17 years ago)
Author:
rainer
Message:

Use thread-safe libc functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/samhain.c

    r96 r131  
    6363
    6464#include "samhain.h"
     65#include "sh_pthread.h"
    6566#include "sh_files.h"
    6667#include "sh_utils.h"
     
    450451  if (0 == strcmp (DEFAULT_MAILADDRESS, _("NULL")))
    451452    {
     453#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_STRTOK_R)
     454      char * saveptr;
     455      (void) sl_strncpy(q, DEFAULT_MAILADDRESS, SH_PATHBUF);
     456      p = strtok_r (q, ", \t", &saveptr);
     457      if (p)
     458        {
     459          (void) sh_mail_setaddress_int (p);
     460          while (NULL != (p = strtok_r (NULL, ", \t", &saveptr)))
     461            (void) sh_mail_setaddress_int (p);
     462        }
     463#else
    452464      (void) sl_strncpy(q, DEFAULT_MAILADDRESS, SH_PATHBUF);
    453465      p = strtok (q, ", \t");
     
    458470            (void) sh_mail_setaddress_int (p);
    459471        }
     472#endif
    460473    }
    461474#endif
     
    747760      return NULL;
    748761    }
     762
     763  SH_MUTEX_LOCK(readdir_lock);
     764
    749765  while (NULL != (d = readdir(dp)) && i < 65535)
    750766    {
     
    767783        }
    768784    }
     785
     786  SH_MUTEX_UNLOCK(readdir_lock);
     787
    769788  closedir(dp);
    770789  return pidlist;
     
    12941313      if ( 0 == strcmp(argv[1], NOCL_CODE) )
    12951314        {
     1315#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_STRTOK_R)
     1316          char * saveptr;
     1317#endif
    12961318          my_argv[0] = argv[0]; ++my_argc; 
    12971319          command_line[0] = '\0';
     
    12991321          command_line[sizeof(command_line)-1] = '\0';
    13001322          do {
     1323#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_STRTOK_R)
    13011324            my_argv[my_argc] =
    1302               strtok( (my_argc == 1) ? command_line : NULL, " \n");
     1325              strtok_r( (my_argc == 1) ? command_line : NULL, " \n", &saveptr);
     1326#else
     1327            my_argv[my_argc] =
     1328              strtok( (my_argc == 1) ? command_line : NULL, " \n");
     1329#endif
    13031330            if (my_argv[my_argc] != NULL) {
    13041331              ++my_argc;
Note: See TracChangeset for help on using the changeset viewer.