Changeset 462 for trunk/src/sh_unix.c


Ignore:
Timestamp:
Jan 16, 2015, 8:45:20 PM (10 years ago)
Author:
katerina
Message:

Fix for ticket #362 (Buffer for getgrnam_r too small).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_unix.c

    r460 r462  
    10121012  struct group     grp;
    10131013  char           * buffer;
     1014  static size_t    gbufsize = SH_GRBUF_SIZE;       
    10141015#endif
    10151016
     
    10351036
    10361037#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)
    1037       buffer = SH_ALLOC(SH_GRBUF_SIZE);
    1038       status = sh_getgrnam_r(g, &grp, buffer, SH_GRBUF_SIZE, &w);
     1038
     1039      buffer = SH_ALLOC(gbufsize);
     1040      status = sh_getgrnam_r(g, &grp, buffer, gbufsize, &w);
     1041
     1042      if ((status == ERANGE) && (w == NULL))
     1043        {
     1044          if (SL_TRUE ==  sl_ok_adds( gbufsize, SH_GRBUF_SIZE ))
     1045            {
     1046              SH_FREE(buffer);
     1047              gbufsize += SH_GRBUF_SIZE;
     1048              goto is_a_name;
     1049            }
     1050        }
     1051
    10391052#else
     1053
    10401054      errno = 0;
    10411055      w = sh_getgrnam(g);
    10421056      status = errno;
     1057
    10431058#endif
    10441059
Note: See TracChangeset for help on using the changeset viewer.