summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-02 14:06:39 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-12-02 14:06:39 +0000
commit83c337f29a1f2d96ad40449364245451cf89b140 (patch)
tree9e0b265035691eeb84e8b1bf1516af6d9dac8d0b /file.c
parentdd7ec71b125d19d0afcfdd56ec5c29ce509e4201 (diff)
merge revision(s) 43853: [Backport #9157]
* file.c (rb_readlink): fix buffer overflow on a long symlink. since rb_str_modify_expand() expands from its length but not its capacity, need to set the length properly for each expansion. [ruby-core:58592] [Bug #9157] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@43959 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/file.c b/file.c
index 53ed9509a0..9dda3fc70d 100644
--- a/file.c
+++ b/file.c
@@ -2531,6 +2531,7 @@ rb_readlink(VALUE path)
) {
rb_str_modify_expand(v, size);
size *= 2;
+ rb_str_set_len(v, size);
}
if (rv < 0) {
rb_str_resize(v, 0);