summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-07-18 07:02:35 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-07-18 07:02:35 +0000
commit12ea63b9e8e8cca66c73e18da094672cbcdd23ae (patch)
treeb91052f172dce8b6d59bf82da17130c571d1baf8
parent882e58cc08a85edb87effb6ec8ea606a63288848 (diff)
downloadruby-12ea63b9e8e8cca66c73e18da094672cbcdd23ae.tar.gz
ruby-12ea63b9e8e8cca66c73e18da094672cbcdd23ae.tar.xz
ruby-12ea63b9e8e8cca66c73e18da094672cbcdd23ae.zip
* 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: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@10558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog11
-rw-r--r--pack.c13
2 files changed, 19 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 7eb42d7b3..de292effe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Tue Jul 18 15:49:42 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * 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.
+
Tue Jul 18 14:38:40 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
* process.c (rb_f_system): call rb_sys_fail(0) if rb_last_status
diff --git a/pack.c b/pack.c
index d031f5955..4bfb95f8b 100644
--- a/pack.c
+++ b/pack.c
@@ -938,6 +938,7 @@ pack_pack(ary, fmt)
associates = rb_ary_new();
}
rb_ary_push(associates, from);
+ rb_obj_taint(from);
rb_str_buf_cat(res, (char*)&t, sizeof(char*));
}
break;
@@ -1890,8 +1891,12 @@ pack_unpack(str, 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;
}
@@ -1900,7 +1905,6 @@ pack_unpack(str, fmt)
if (p == pend) {
rb_raise(rb_eArgError, "non associated pointer");
}
- tmp = rb_tainted_str_new(t, len);
}
else {
tmp = Qnil;
@@ -1932,6 +1936,7 @@ pack_unpack(str, fmt)
pend = p + RARRAY(a)->len;
while (p < pend) {
if (TYPE(*p) == T_STRING && RSTRING(*p)->ptr == t) {
+ tmp = *p;
break;
}
p++;
@@ -1939,8 +1944,6 @@ pack_unpack(str, fmt)
if (p == pend) {
rb_raise(rb_eArgError, "non associated pointer");
}
- tmp = rb_str_new2(t);
- OBJ_INFECT(tmp, str);
}
else {
tmp = Qnil;