aboutsummaryrefslogtreecommitdiffstats
path: root/process.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-10 23:34:33 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-05-10 23:34:33 +0000
commitd4e129f23065a01fc0c0a60dd9cea6145c67d37a (patch)
tree7a7c24feb92c636285dde3002d3e7033dd67fbe2 /process.c
parentb346ea7a0102e80d392f85227e6ffa5545e204b5 (diff)
downloadruby-d4e129f23065a01fc0c0a60dd9cea6145c67d37a.tar.gz
.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/process.c b/process.c
index 27a12f8635..8b5cf0cff6 100644
--- a/process.c
+++ b/process.c
@@ -173,6 +173,11 @@ static void check_gid_switch(void);
VALUE getpw_buf = 0
# define FINISH_GETPWNAM \
(getpw_buf ? (void)rb_str_resize(getpw_buf, 0) : (void)0)
+# ifdef __APPLE__
+# define GETPWNAM_R_RETRY_P(e) (e == 0 || e == ERANGE)
+# else
+# define GETPWNAM_R_RETRY_P(e) (e == ERANGE)
+# endif
# define OBJ2UID1(id) obj2uid((id), &getpw_buf)
# define OBJ2UID(id) obj2uid0(id)
static rb_uid_t obj2uid(VALUE id, VALUE *getpw_buf);
@@ -215,6 +220,11 @@ static rb_uid_t obj2uid(VALUE id);
VALUE getgr_buf = 0
# define FINISH_GETGRNAM \
(getgr_buf ? (void)rb_str_resize(getgr_buf, 0) : (void)0)
+# ifdef __APPLE__
+# define GETGRNAM_R_RETRY_P(e) (e == 0 || e == ERANGE)
+# else
+# define GETGRNAM_R_RETRY_P(e) (e == ERANGE)
+# endif
# define OBJ2GID1(id) obj2gid((id), &getgr_buf)
# define OBJ2GID(id) obj2gid0(id)
static rb_gid_t obj2gid(VALUE id, VALUE *getgr_buf);
@@ -5042,7 +5052,7 @@ obj2uid(VALUE id
/* gepwnam_r() on MacOS X doesn't set errno if buffer size is insufficient */
while (getpwnam_r(usrname, &pwbuf, getpw_buf, getpw_buf_len, &pwptr)) {
int e = errno;
- if (e != ERANGE || getpw_buf_len >= GETPW_R_SIZE_LIMIT) {
+ if (!GETPWNAM_R_RETRY_P(e) || getpw_buf_len >= GETPW_R_SIZE_LIMIT) {
rb_str_resize(*getpw_tmp, 0);
rb_syserr_fail(e, "getpwnam_r");
}
@@ -5120,7 +5130,7 @@ obj2gid(VALUE id
/* gegrnam_r() on MacOS X doesn't set errno if buffer size is insufficient */
while (getgrnam_r(grpname, &grbuf, getgr_buf, getgr_buf_len, &grptr)) {
int e = errno;
- if (e != ERANGE || getgr_buf_len >= GETGR_R_SIZE_LIMIT) {
+ if (!GETGRNAM_R_RETRY_P(e) || getgr_buf_len >= GETGR_R_SIZE_LIMIT) {
rb_str_resize(*getgr_tmp, 0);
rb_syserr_fail(e, "getgrnam_r");
}