summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-30 10:53:59 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-30 10:53:59 +0000
commitd4f03fab29b08a11f5ced7087785a20296971283 (patch)
treedb30894e586739b1f45abf5b82f4307b48546a3b
parent8f01d618e8e4960265696f0ea11cbcbb941fc2ce (diff)
merge revision(s) 58658: [Backport #13554]
process.c: temporary string for buffer * process.c (obj2uid, obj2gid): use temporary string as the buffer instead of `rb_alloc_tmp_buffer`, which is `NODE_ALLOCA` since r51492. [ruby-core:81084] [Bug #13554] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@59220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--process.c26
-rw-r--r--version.h2
3 files changed, 19 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index b78aedff8b..832bfb9f1a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Fri Jun 30 19:53:30 2017 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * process.c (obj2uid, obj2gid): use temporary string as the buffer
+ instead of rb_alloc_tmp_buffer, which is NODE_ALLOCA since r51492.
+ [Bug #13554]
+
Fri Jun 30 19:50:25 2017 Eric Wong <e@80x24.org>
* variable.c (autoload_reset): use idempotent list_del_init
diff --git a/process.c b/process.c
index e6840aab1b..b2d4ee1a66 100644
--- a/process.c
+++ b/process.c
@@ -172,7 +172,7 @@ static void check_gid_switch(void);
# define PREPARE_GETPWNAM \
VALUE getpw_buf = 0
# define FINISH_GETPWNAM \
- ALLOCV_END(getpw_buf)
+ (getpw_buf ? (void)rb_str_resize(getpw_buf, 0) : (void)0)
# define OBJ2UID1(id) obj2uid((id), &getpw_buf)
# define OBJ2UID(id) obj2uid0(id)
static rb_uid_t obj2uid(VALUE id, VALUE *getpw_buf);
@@ -214,7 +214,7 @@ static rb_uid_t obj2uid(VALUE id);
# define PREPARE_GETGRNAM \
VALUE getgr_buf = 0
# define FINISH_GETGRNAM \
- ALLOCV_END(getgr_buf)
+ (getgr_buf ? (void)rb_str_resize(getgr_buf, 0) : (void)0)
# define OBJ2GID1(id) obj2gid((id), &getgr_buf)
# define OBJ2GID(id) obj2gid0(id)
static rb_gid_t obj2gid(VALUE id, VALUE *getgr_buf);
@@ -5051,18 +5051,17 @@ obj2uid(VALUE id
if (!*getpw_tmp) {
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 {
- getpw_buf = RSTRING_PTR(*getpw_tmp);
- getpw_buf_len = rb_str_capacity(*getpw_tmp);
+ *getpw_tmp = rb_str_tmp_new(getpw_buf_len);
}
+ getpw_buf = RSTRING_PTR(*getpw_tmp);
+ getpw_buf_len = rb_str_capacity(*getpw_tmp);
+ rb_str_set_len(*getpw_tmp, getpw_buf_len);
errno = ERANGE;
/* 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) {
- rb_free_tmp_buffer(getpw_tmp);
+ rb_str_resize(*getpw_tmp, 0);
rb_syserr_fail(e, "getpwnam_r");
}
rb_str_modify_expand(*getpw_tmp, getpw_buf_len);
@@ -5130,18 +5129,17 @@ obj2gid(VALUE id
if (!*getgr_tmp) {
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 {
- getgr_buf = RSTRING_PTR(*getgr_tmp);
- getgr_buf_len = rb_str_capacity(*getgr_tmp);
+ *getgr_tmp = rb_str_tmp_new(getgr_buf_len);
}
+ getgr_buf = RSTRING_PTR(*getgr_tmp);
+ getgr_buf_len = rb_str_capacity(*getgr_tmp);
+ rb_str_set_len(*getgr_tmp, getgr_buf_len);
errno = ERANGE;
/* 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) {
- rb_free_tmp_buffer(getgr_tmp);
+ rb_str_resize(*getgr_tmp, 0);
rb_syserr_fail(e, "getgrnam_r");
}
rb_str_modify_expand(*getgr_tmp, getgr_buf_len);
diff --git a/version.h b/version.h
index d3738f20ed..c946ff3dd5 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.3.5"
#define RUBY_RELEASE_DATE "2017-06-30"
-#define RUBY_PATCHLEVEL 316
+#define RUBY_PATCHLEVEL 317
#define RUBY_RELEASE_YEAR 2017
#define RUBY_RELEASE_MONTH 6