summaryrefslogtreecommitdiff
path: root/pack.c
diff options
context:
space:
mode:
Diffstat (limited to 'pack.c')
-rw-r--r--pack.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/pack.c b/pack.c
index d031f5955d..4bfb95f8be 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;