aboutsummaryrefslogtreecommitdiffstats
path: root/marshal.c
diff options
context:
space:
mode:
Diffstat (limited to 'marshal.c')
-rw-r--r--marshal.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/marshal.c b/marshal.c
index b01d2de201..676f4f8eef 100644
--- a/marshal.c
+++ b/marshal.c
@@ -137,6 +137,7 @@ struct dump_arg {
st_table *symbols;
st_table *data;
int taint;
+ int untrust;
st_table *compat_tbl;
VALUE wrapper;
st_table *encodings;
@@ -192,6 +193,7 @@ w_nbyte(const char *s, int n, struct dump_arg *arg)
rb_str_buf_cat(buf, s, n);
if (arg->dest && RSTRING_LEN(buf) >= BUFSIZ) {
if (arg->taint) OBJ_TAINT(buf);
+ if (arg->untrust) OBJ_UNTRUST(buf);
rb_io_write(arg->dest, buf);
rb_str_resize(buf, 0);
}
@@ -581,6 +583,7 @@ w_object(VALUE obj, struct dump_arg *arg, int limit)
}
else {
if (OBJ_TAINTED(obj)) arg->taint = Qtrue;
+ if (OBJ_UNTRUSTED(obj)) arg->untrust = Qtrue;
if (rb_respond_to(obj, s_mdump)) {
volatile VALUE v;
@@ -809,6 +812,9 @@ dump_ensure(struct dump_arg *arg)
if (arg->taint) {
OBJ_TAINT(arg->str);
}
+ if (arg->untrust) {
+ OBJ_UNTRUST(arg->str);
+ }
return 0;
}
@@ -878,6 +884,7 @@ marshal_dump(int argc, VALUE *argv)
arg.symbols = st_init_numtable();
arg.data = st_init_numtable();
arg.taint = Qfalse;
+ arg.untrust = Qfalse;
arg.compat_tbl = st_init_numtable();
arg.wrapper = Data_Wrap_Struct(rb_cData, mark_dump_arg, 0, &arg);
arg.encodings = 0;
@@ -900,6 +907,7 @@ struct load_arg {
VALUE data;
VALUE proc;
int taint;
+ int untrust;
st_table *compat_tbl;
VALUE compat_tbl_wrapper;
};
@@ -1014,6 +1022,7 @@ r_bytes0(long len, struct load_arg *arg)
StringValue(str);
if (RSTRING_LEN(str) != len) goto too_short;
if (OBJ_TAINTED(str)) arg->taint = Qtrue;
+ if (OBJ_UNTRUSTED(str)) arg->untrust = Qtrue;
}
return str;
}
@@ -1084,6 +1093,11 @@ r_entry(VALUE v, struct load_arg *arg)
if ((VALUE)real_obj != Qundef)
OBJ_TAINT((VALUE)real_obj);
}
+ if (arg->untrust) {
+ OBJ_UNTRUST(v);
+ if ((VALUE)real_obj != Qundef)
+ OBJ_UNTRUST((VALUE)real_obj);
+ }
return v;
}