summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-08 04:08:46 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-03-08 04:08:46 +0000
commit9e33b72ad154eeb5fb1ff257d90340a1ae767df1 (patch)
treee342da703e3eda34442d157dbce09ca7e5cdb793
parentb1fb57da3d6797691506bb9954d166bb2bd56555 (diff)
process.c: GETPW_R_SIZE_INIT, GETGR_R_SIZE_INIT
* process.c (GETPW_R_SIZE_INIT, GETGR_R_SIZE_INIT): sysconf values are not maximum sizes, but initial sizes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45288 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--process.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/process.c b/process.c
index 0f3c6a2..1abc82a 100644
--- a/process.c
+++ b/process.c
@@ -151,6 +151,8 @@ static void check_gid_switch(void);
#if defined(HAVE_PWD_H)
# if defined(HAVE_GETPWNAM_R) && defined(_SC_GETPW_R_SIZE_MAX)
# define USE_GETPWNAM_R 1
+# define GETPW_R_SIZE_INIT sysconf(_SC_GETPW_R_SIZE_MAX)
+# define GETPW_R_SIZE_DEFAULT 0x1000
# endif
# ifdef USE_GETPWNAM_R
# define PREPARE_GETPWNAM \
@@ -188,6 +190,8 @@ static rb_uid_t obj2uid(VALUE id);
#if defined(HAVE_GRP_H)
# if defined(HAVE_GETGRNAM_R) && defined(_SC_GETGR_R_SIZE_MAX)
# define USE_GETGRNAM_R
+# define GETGR_R_SIZE_INIT sysconf(_SC_GETGR_R_SIZE_MAX)
+# define GETGR_R_SIZE_DEFAULT 0x1000
# endif
# ifdef USE_GETGRNAM_R
# define PREPARE_GETGRNAM \
@@ -4729,8 +4733,8 @@ obj2uid(VALUE id
char *getpw_buf;
long getpw_buf_len;
if (!*getpw_tmp) {
- getpw_buf_len = sysconf(_SC_GETPW_R_SIZE_MAX);
- if (getpw_buf_len < 0) getpw_buf_len = 4096;
+ getpw_buf_len = GETPW_R_SIZE_INIT;
+ if (getpw_buf_len < 0) getpw_buf_len = GETPW_R_SIZE_DEFAULT;
getpw_buf = rb_alloc_tmp_buffer(getpw_tmp, getpw_buf_len);
}
else {
@@ -4797,8 +4801,8 @@ obj2gid(VALUE id
char *getgr_buf;
long getgr_buf_len;
if (!*getgr_tmp) {
- getgr_buf_len = sysconf(_SC_GETGR_R_SIZE_MAX);
- if (getgr_buf_len < 0) getgr_buf_len = 4096;
+ getgr_buf_len = GETGR_R_SIZE_INIT;
+ if (getgr_buf_len < 0) getgr_buf_len = GETGR_R_SIZE_DEFAULT;
getgr_buf = rb_alloc_tmp_buffer(getgr_tmp, getgr_buf_len);
}
else {