aboutsummaryrefslogtreecommitdiffstats
path: root/process.c
diff options
context:
space:
mode:
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");
}