Changeset 227 for trunk/src/sh_unix.c


Ignore:
Timestamp:
Apr 20, 2009, 5:59:31 PM (16 years ago)
Author:
katerina
Message:

Fix warnings with -fstack-check

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_unix.c

    r221 r227  
    990990#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)
    991991  struct passwd    pwd;
    992   char             buffer[SH_PWBUF_SIZE];
     992  char           * buffer;
    993993#endif
    994994 
     
    998998   */
    999999#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)
    1000   sh_getpwnam_r(c, &pwd, buffer, sizeof(buffer), &w);
     1000  buffer = SH_ALLOC(SH_PWBUF_SIZE);
     1001  sh_getpwnam_r(c, &pwd, buffer, SH_PWBUF_SIZE, &w);
    10011002#else
    10021003  w = sh_getpwnam(c);
     
    10141015  sh_error_handle ((-1), FIL__, __LINE__, EINVAL, MSG_EINVALS,
    10151016                   _("add trusted user"), c);
     1017#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)
     1018  SH_FREE(buffer);
     1019#endif
    10161020  SL_RETURN((-1), _("tf_add_trusted_user_int"));
    10171021
    10181022 succe:
    10191023  count = sl_trust_add_user(pwid);
     1024#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)
     1025  SH_FREE(buffer);
     1026#endif
    10201027  SL_RETURN((count), _("tf_add_trusted_user_int"));
    10211028}
     
    10921099#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)
    10931100      struct passwd    pwd;
    1094       char             buffer[SH_PWBUF_SIZE];
     1101      char          *  buffer = SH_ALLOC(SH_PWBUF_SIZE);
    10951102      struct passwd *  tempres;
    1096       sh_getpwnam_r(DEFAULT_IDENT, &pwd, buffer, sizeof(buffer), &tempres);
     1103      sh_getpwnam_r(DEFAULT_IDENT, &pwd, buffer, SH_PWBUF_SIZE, &tempres);
    10971104#else
    10981105      struct passwd * tempres = sh_getpwnam(DEFAULT_IDENT);
     
    11071114        }
    11081115      ff_euid = tempres->pw_uid;
     1116#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)
     1117      SH_FREE(buffer);
     1118#endif
    11091119    }
    11101120#endif
     
    24692479#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWUID_R)
    24702480  struct passwd pwd;
    2471   char   buffer[SH_PWBUF_SIZE];
     2481  char   * buffer;
    24722482#endif
    24732483  char errbuf[SH_ERRBUF_SIZE];
     
    24762486
    24772487#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWUID_R)
    2478   sh_getpwuid_r(uid, &pwd, buffer, sizeof(buffer), &tempres);
     2488  buffer = SH_ALLOC(SH_PWBUF_SIZE);
     2489  sh_getpwuid_r(uid, &pwd, buffer, SH_PWBUF_SIZE, &tempres);
    24792490#else
    24802491  errno = 0;
     
    24872498                     sh_error_message(status, errbuf, sizeof(errbuf)),
    24882499                     _("getpwuid"), (long) uid, _("completely missing"));
     2500#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
     2501    SH_FREE(buffer);
     2502#endif
    24892503    SL_RETURN( NULL, _("sh_unix_getUIDdir"));
    24902504  }
     
    24922506  if (tempres->pw_dir != NULL) {
    24932507    sl_strlcpy(out, tempres->pw_dir, len);
     2508#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
     2509    SH_FREE(buffer);
     2510#endif
    24942511    SL_RETURN( out, _("sh_unix_getUIDdir"));
    24952512  } else {
     
    24972514                     sh_error_message(status, errbuf, sizeof(errbuf)),
    24982515                     _("getpwuid"), (long) uid, _("pw_dir"));
     2516#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
     2517    SH_FREE(buffer);
     2518#endif
    24992519    SL_RETURN( NULL, _("sh_unix_getUIDdir"));
    25002520  }
     
    25082528#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWUID_R)
    25092529  struct passwd pwd;
    2510   char   buffer[SH_PWBUF_SIZE];
     2530  char   * buffer;
    25112531#endif
    25122532  int             status = 0;
     
    25292549
    25302550#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWUID_R)
    2531   sh_getpwuid_r(uid, &pwd, buffer, sizeof(buffer), &tempres);
     2551  buffer = SH_ALLOC(SH_PWBUF_SIZE);
     2552  sh_getpwuid_r(uid, &pwd, buffer, SH_PWBUF_SIZE, &tempres);
    25322553#else
    25332554  errno = 0;
     
    25402561                     sh_error_message(status, errbuf, sizeof(errbuf)),
    25412562                     _("getpwuid"), (long) uid, _("completely missing"));
     2563#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
     2564    SH_FREE(buffer);
     2565#endif
    25422566    SL_RETURN( NULL, _("sh_unix_getUIDname"));
    25432567  }
     
    25502574    sl_strlcpy(out, name, len);
    25512575    SH_MUTEX_UNLOCK_UNSAFE(mutex_getUIDname);
     2576#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
     2577    SH_FREE(buffer);
     2578#endif
    25522579    SL_RETURN( out, _("sh_unix_getUIDname"));
    25532580  } else {
     
    25552582                     sh_error_message(status, errbuf, sizeof(errbuf)),
    25562583                     _("getpwuid"), (long) uid, _("pw_user"));
     2584#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
     2585    SH_FREE(buffer);
     2586#endif
    25572587    SL_RETURN( NULL, _("sh_unix_getUIDname"));
    25582588  }
     
    25692599#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
    25702600  struct group    grp;
    2571   char            buffer[SH_GRBUF_SIZE];
     2601  char          * buffer;
    25722602#endif
    25732603  char errbuf[SH_ERRBUF_SIZE];
     
    25882618
    25892619#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
    2590   status = sh_getgrgid_r(gid, &grp, buffer, sizeof(buffer), &tempres);
     2620  buffer = SH_ALLOC(SH_GRBUF_SIZE);
     2621  status = sh_getgrgid_r(gid, &grp, buffer, SH_GRBUF_SIZE, &tempres);
    25912622#else
    25922623  errno = 0;
     
    26002631                     _("getgrgid"), (long) gid, _("completely missing"));
    26012632     
     2633#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
     2634    SH_FREE(buffer);
     2635#endif
    26022636    SL_RETURN( NULL, _("sh_unix_getGIDname"));
    26032637  }
     
    26092643    sl_strlcpy(out, name, len);
    26102644    SH_MUTEX_UNLOCK_UNSAFE(mutex_getGIDname);
     2645#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
     2646    SH_FREE(buffer);
     2647#endif
    26112648    SL_RETURN( out, _("sh_unix_getGIDname"));
    26122649  } else {
     
    26142651                     sh_error_message(status, errbuf, sizeof(errbuf)),
    26152652                     _("getgrgid"), (long) gid, _("gr_name"));
     2653#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R)
     2654    SH_FREE(buffer);
     2655#endif
    26162656    SL_RETURN( NULL, _("sh_unix_getGIDname"));
    26172657  }
     
    31363176                           char * fileHash, int alert_timeout, SL_TICKET fd)
    31373177{
    3138   file_type tmpFile;
     3178  file_type * tmpFile;
    31393179  int status;
    31403180
    31413181  SL_ENTER(_("sh_unix_checksum_size"));
    31423182
    3143   tmpFile.link_path = NULL;
     3183  tmpFile = SH_ALLOC(sizeof(file_type));
     3184  tmpFile->link_path = NULL;
    31443185
    31453186  if (sh.flag.checkSum != SH_CHECK_INIT)
    31463187    {
    31473188      /* lookup file in database */
    3148       status = sh_hash_get_it (filename, &tmpFile);
     3189      status = sh_hash_get_it (filename, tmpFile);
    31493190      if (status != 0) {
    31503191        goto out;
     
    31533194  else
    31543195    {
    3155       tmpFile.size = fbuf->st_size;
     3196      tmpFile->size = fbuf->st_size;
    31563197    }
    31573198
    31583199  /* if last < current get checksum */
    3159   if (tmpFile.size < fbuf->st_size)
     3200  if (tmpFile->size < fbuf->st_size)
    31603201    {
    31613202      char hashbuf[KEYBUF_SIZE];
    3162       UINT64 local_length = (UINT64) (tmpFile.size < 0 ? 0 : tmpFile.size);
     3203      UINT64 local_length = (UINT64) (tmpFile->size < 0 ? 0 : tmpFile->size);
    31633204      sl_strlcpy(fileHash,
    31643205                 sh_tiger_generic_hash (filename, fd, &(local_length),
     
    31673208     
    31683209       /* return */
    3169       if (tmpFile.link_path)   SH_FREE(tmpFile.link_path);
     3210      if (tmpFile->link_path)   SH_FREE(tmpFile->link_path);
     3211      SH_FREE(tmpFile);
    31703212      SL_RETURN( 0, _("sh_unix_checksum_size"));
    31713213    }
    31723214
    31733215 out:
    3174   if (tmpFile.link_path)   SH_FREE(tmpFile.link_path);
     3216  if (tmpFile->link_path)   SH_FREE(tmpFile->link_path);
     3217  SH_FREE(tmpFile);
    31753218  sl_strlcpy(fileHash, SH_KEY_NULL, KEY_LEN+1);
    31763219  SL_RETURN( -1, _("sh_unix_checksum_size"));
Note: See TracChangeset for help on using the changeset viewer.