Project

General

Profile

Bug #13960

ARGF.inplace_mode= が SHARABLE_MIDDLE_SUBSTRING=1 を考慮していない

Added by tommy (Masahiro Tomita) almost 2 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.0dev (2017-10-01 trunk 60085) [x86_64-linux]
[ruby-dev:50272]

Description

SHARABLE_MIDDLE_SUBSTRING=1 でコンパイルしたRubyで、ARGF.inplace_mode= がNUL終端まで文字列を使用してしまいます。

% echo hoge > hoge
% ruby -e 'ARGF.inplace_mode=(".abcdefghijklmnopqrstuvwxyz"*2)[0,27]; ARGF.each_line{|line| print line.sub("hoge","fuga")}' hoge
% ls hoge*   
hoge  hoge.abcdefghijklmnopqrstuvwxyz.abcdefghijklmnopqrstuvwxyz

次のパッチで直ると思います。

diff --git a/io.c b/io.c
index 1254e92363..ed4a562d8b 100644
--- a/io.c
+++ b/io.c
@@ -12224,7 +12224,7 @@ argf_inplace_mode_set(VALUE argf, VALUE val)
    ARGF.inplace = 0;
     }
     else {
-   StringValue(val);
+   StringValueCStr(val);
    if (ARGF.inplace) free(ARGF.inplace);
    ARGF.inplace = 0;
    ARGF.inplace = strdup(RSTRING_PTR(val));

Associated revisions

Revision 8148b701
Added by nobu (Nobuyoshi Nakada) almost 2 years ago

io.c: check null char

  • io.c (ruby_set_inplace_mode): check if null is contained. based on the patch by tommy (Masahiro Tomita) in [ruby-dev:50272]. [Bug #13960]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 60097
Added by nobu (Nobuyoshi Nakada) almost 2 years ago

io.c: check null char

  • io.c (ruby_set_inplace_mode): check if null is contained. based on the patch by tommy (Masahiro Tomita) in [ruby-dev:50272]. [Bug #13960]

Revision 60097
Added by nobu (Nobuyoshi Nakada) almost 2 years ago

io.c: check null char

  • io.c (ruby_set_inplace_mode): check if null is contained. based on the patch by tommy (Masahiro Tomita) in [ruby-dev:50272]. [Bug #13960]

Revision 60097
Added by nobu (Nobuyoshi Nakada) almost 2 years ago

io.c: check null char

  • io.c (ruby_set_inplace_mode): check if null is contained. based on the patch by tommy (Masahiro Tomita) in [ruby-dev:50272]. [Bug #13960]

History

#1

Updated by nobu (Nobuyoshi Nakada) almost 2 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r60097.


io.c: check null char

  • io.c (ruby_set_inplace_mode): check if null is contained. based on the patch by tommy (Masahiro Tomita) in [ruby-dev:50272]. [Bug #13960]

Also available in: Atom PDF