diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-07-18 07:02:35 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-07-18 07:02:35 +0000 |
commit | df80a7b4bb326d701cbee9849cd47f19a45ff32e (patch) | |
tree | e73281b93b9a4a6f09c944450fa6f6f262ac9abd /pack.c | |
parent | 9d6e1cdb73e59ac188fa10a35cbc8a11f1d2a4d7 (diff) | |
download | ruby-df80a7b4bb326d701cbee9849cd47f19a45ff32e.tar.gz |
* pack.c (pack_unpack): propagate association array to copied
string. [ruby-core:08223]
* pack.c (pack_unpack): return referenced string itself if it has
same length as specified. a patch from <nobu at ruby-lang.org>
in [ruby-core:08225].
* pack.c (pack_pack): taint 'p' packed strings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'pack.c')
-rw-r--r-- | pack.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -932,6 +932,7 @@ pack_pack(VALUE ary, VALUE fmt) associates = rb_ary_new(); } rb_ary_push(associates, from); + rb_obj_taint(from); rb_str_buf_cat(res, (char*)&t, sizeof(char*)); } break; @@ -1873,8 +1874,12 @@ pack_unpack(VALUE str, VALUE fmt) pend = p + RARRAY(a)->len; while (p < pend) { if (TYPE(*p) == T_STRING && RSTRING(*p)->ptr == t) { - if (len > RSTRING(*p)->len) { - len = RSTRING(*p)->len; + if (len < RSTRING(*p)->len) { + tmp = rb_tainted_str_new(t, len); + rb_str_associate(tmp, a); + } + else { + tmp = *p; } break; } @@ -1883,7 +1888,6 @@ pack_unpack(VALUE str, VALUE fmt) if (p == pend) { rb_raise(rb_eArgError, "non associated pointer"); } - tmp = rb_tainted_str_new(t, len); } else { tmp = Qnil; @@ -1915,6 +1919,7 @@ pack_unpack(VALUE str, VALUE fmt) pend = p + RARRAY(a)->len; while (p < pend) { if (TYPE(*p) == T_STRING && RSTRING(*p)->ptr == t) { + tmp = *p; break; } p++; @@ -1922,8 +1927,6 @@ pack_unpack(VALUE str, VALUE fmt) if (p == pend) { rb_raise(rb_eArgError, "non associated pointer"); } - tmp = rb_str_new2(t); - OBJ_INFECT(tmp, str); } else { tmp = Qnil; |