Permalink
Browse files

remove code for unsupported taint-mode

  • Loading branch information...
1 parent 1605ec8 commit d4ef3baca86fdf54c76db53fafa45116651782c9 @matz matz committed Apr 23, 2012
Showing with 13 additions and 87 deletions.
  1. +2 −17 src/array.c
  2. +0 −1 src/enum.c
  3. +2 −3 src/kernel.c
  4. +0 −1 src/object.c
  5. +0 −2 src/range.c
  6. +7 −22 src/re.c
  7. +0 −7 src/sprintf.c
  8. +2 −33 src/string.c
  9. +0 −1 src/struct.c
View
@@ -1001,24 +1001,19 @@ inspect_ary(mrb_state *mrb, mrb_value ary, mrb_value list)
static mrb_value
inspect_ary_r(mrb_state *mrb, mrb_value ary, mrb_value dummy, int recur)
{
- //int tainted = OBJ_TAINTED(ary);
- //int untrust = OBJ_UNTRUSTED(ary);
long i;
mrb_value s, arystr;
- //if (recur) return mrb_tainted_str_new2("[...]");
+
arystr = mrb_str_buf_new(mrb, 128);
mrb_str_buf_cat(mrb, arystr, "[", strlen("[")); /* for capa */
//arystr = mrb_str_new_cstr(mrb, "[");//mrb_str_buf_new2("[");
for (i=0; i<RARRAY_LEN(ary); i++) {
s = mrb_inspect(mrb, RARRAY_PTR(ary)[i]);//mrb_inspect(RARRAY_PTR(ary)[i]);
- //if (OBJ_TAINTED(s)) tainted = TRUE;
- //if (OBJ_UNTRUSTED(s)) untrust = TRUE;
if (i > 0) mrb_str_buf_cat(mrb, arystr, ", ", strlen(", "));//mrb_str_buf_cat2(str, ", ");
mrb_str_buf_append(mrb, arystr, s);
}
mrb_str_buf_cat(mrb, arystr, "]", strlen("]"));// mrb_str_buf_cat2(str, "]");
- //if (tainted) OBJ_TAINT(str);
- //if (untrust) OBJ_UNTRUST(str);
+
return arystr;
}
#endif
@@ -1138,8 +1133,6 @@ ary_join_0(mrb_state *mrb, mrb_value ary, mrb_value sep, long max, mrb_value res
if (i > 0 && !mrb_nil_p(sep))
mrb_str_buf_append(mrb, result, sep);
mrb_str_buf_append(mrb, result, val);
- //if (OBJ_TAINTED(val)) OBJ_TAINT(result);
- //if (OBJ_UNTRUSTED(val)) OBJ_TAINT(result);
}
}
@@ -1205,13 +1198,9 @@ mrb_value
mrb_ary_join(mrb_state *mrb, mrb_value ary, mrb_value sep)
{
long len = 1, i;
- //int taint = FALSE;
- //int untrust = FALSE;
mrb_value val, tmp, result;
if (RARRAY_LEN(ary) == 0) return mrb_str_new2(mrb, "");
- //if (OBJ_TAINTED(ary) || OBJ_TAINTED(sep)) taint = TRUE;
- //if (OBJ_UNTRUSTED(ary) || OBJ_UNTRUSTED(sep)) untrust = TRUE;
if (!mrb_nil_p(sep)) {
//StringValue(sep);
@@ -1227,8 +1216,6 @@ mrb_ary_join(mrb_state *mrb, mrb_value ary, mrb_value sep)
mrb_value first;
result = mrb_str_buf_new(mrb, len + (RARRAY_LEN(ary)-i)*10);
- //if (taint) OBJ_TAINT(result);
- //if (untrust) OBJ_UNTRUST(result);
first = (i == 0)? mrb_true_value(): mrb_false_value();
mrb_realloc(mrb, RSTRING(result)->buf, ++(RSTRING(result)->capa));
ary_join_0(mrb, ary, sep, i, result);
@@ -1242,8 +1229,6 @@ mrb_realloc(mrb, RSTRING(result)->buf, ++(RSTRING(result)->capa));
}
result = mrb_str_buf_new(mrb, len);
- //if (taint) OBJ_TAINT(result);
- //if (untrust) OBJ_UNTRUST(result);
ary_join_0(mrb, ary, sep, RARRAY_LEN(ary), result);
return result;
View
@@ -413,7 +413,6 @@ enum_to_a(mrb_state *mrb, int argc, mrb_value *argv, mrb_value obj)
mrb_value ary = mrb_ary_new(mrb);
mrb_block_call(mrb, obj, id_each, argc, argv, collect_all, &ary);
- //OBJ_INFECT(ary, obj);
return ary;
}
View
@@ -408,7 +408,7 @@ init_copy(mrb_state *mrb, mrb_value dest, mrb_value obj)
*
* Produces a shallow copy of <i>obj</i>---the instance variables of
* <i>obj</i> are copied, but not the objects they reference. Copies
- * the frozen and tainted state of <i>obj</i>. See also the discussion
+ * the frozen state of <i>obj</i>. See also the discussion
* under <code>Object#dup</code>.
*
* class Klass
@@ -437,7 +437,6 @@ mrb_obj_clone(mrb_state *mrb, mrb_value self)
}
clone = mrb_obj_alloc(mrb, self.tt, mrb_obj_class(mrb, self));
clone->c = mrb_singleton_class_clone(mrb, self);
- //RBASIC(clone)->flags = (RBASIC(obj)->flags | FL_TEST(clone, FL_TAINT) | FL_TEST(clone, FL_UNTRUSTED)) & ~(FL_FREEZE|FL_FINALIZE);
init_copy(mrb, mrb_obj_value(clone), self);
//1-9-2 no bug mrb_funcall(mrb, clone, "initialize_clone", 1, self);
//RBASIC(clone)->flags |= RBASIC(obj)->flags & FL_FREEZE;
@@ -452,7 +451,7 @@ mrb_obj_clone(mrb_state *mrb, mrb_value self)
*
* Produces a shallow copy of <i>obj</i>---the instance variables of
* <i>obj</i> are copied, but not the objects they reference.
- * <code>dup</code> copies the tainted state of <i>obj</i>. See also
+ * <code>dup</code> copies the frozen state of <i>obj</i>. See also
* the discussion under <code>Object#clone</code>. In general,
* <code>clone</code> and <code>dup</code> may have different semantics
* in descendant classes. While <code>clone</code> is used to duplicate
View
@@ -478,7 +478,6 @@ mrb_any_to_s(mrb_state *mrb, mrb_value obj)
// snprintf(RSTRING(str)->ptr, len+1, "#<%s:0x%lx>", cname, obj);
sprintf(s->buf, "#<%s:0x%lx>", cname, (unsigned long)(obj.value.p));
s->len = strlen(s->buf);
- /*if (OBJ_TAINTED(obj)) OBJ_TAINT(str);*/
return str;
}
View
@@ -377,7 +377,6 @@ range_to_s(mrb_state *mrb, mrb_value range)
str = mrb_str_dup(mrb, str);
mrb_str_cat(mrb, str, "...", r->excl ? 3 : 2);
mrb_str_append(mrb, str, str2);
- //OBJ_INFECT(str, str2);
return str;
}
@@ -396,7 +395,6 @@ inspect_range(mrb_state *mrb, mrb_value range, mrb_value dummy, int recur)
str = mrb_str_dup(mrb, str);
mrb_str_cat(mrb, str, "...", r->excl ? 3 : 2);
mrb_str_append(mrb, str, str2);
- // OBJ_INFECT(str, str2);
return str;
}
View
@@ -189,7 +189,7 @@ mrb_reg_quote(mrb_state *mrb, mrb_value str)
t += mrb_enc_mbcput(c, t, enc);
}
mrb_str_resize(mrb, tmp, t - RSTRING_PTR(tmp));
- /*OBJ_INFECT(tmp, str);*/
+
return tmp;
}
@@ -263,7 +263,7 @@ mrb_reg_nth_match(mrb_state *mrb, mrb_int nth, mrb_value match)
end = m->rmatch->regs.end[nth];
len = end - start;
str = mrb_str_substr(mrb, m->str, start, len);
- /*OBJ_INFECT(str, match);*/
+
return str;
}
@@ -458,7 +458,7 @@ mrb_reg_desc(mrb_state *mrb, const char *s, long len, mrb_value re)
if (RBASIC(re)->flags & REG_ENCODING_NONE)
mrb_str_buf_cat(mrb, str, "n", strlen("n"));//mrb_str_buf_cat2(str, "n");
}
- /*OBJ_INFECT(str, re);*/
+
return str;
}
static void
@@ -580,21 +580,12 @@ mrb_reg_search(mrb_state *mrb, mrb_value re, mrb_value str, mrb_int pos, mrb_int
onig_region_copy(RMATCH_REGS(match), regs);
onig_region_free(regs, 0);
}
- /*else {
- if (mrb_safe_level() >= 3)
- OBJ_TAINT(match);
- else
- FL_UNSET(match, FL_TAINT);
- }*/
RMATCH(match)->str = str_new4(mrb, str.tt, str);
RMATCH(match)->regexp = re;
RMATCH(match)->rmatch->char_offset_updated = 0;
mrb_backref_set(mrb, match);
- //OBJ_INFECT(match, re);
- //OBJ_INFECT(match, str);
-
return result;
}
@@ -1248,8 +1239,7 @@ mrb_reg_initialize_str(mrb_state *mrb, mrb_value obj, mrb_value str, int options
ret = mrb_reg_initialize(mrb, obj, RSTRING_PTR(str), RSTRING_LEN(str), enc,
options, err, sourcefile, sourceline);
- /*OBJ_INFECT(obj, str);
- RB_GC_GUARD(str);*/
+
return ret;
}
@@ -1642,7 +1632,6 @@ mrb_reg_source(mrb_state *mrb, mrb_value re)
mrb_reg_check(mrb, re);
str = mrb_enc_str_new(mrb, RREGEXP_SRC_PTR(re),RREGEXP_SRC_LEN(re), mrb_enc_get(mrb, re));
- /*if (OBJ_TAINTED(re)) OBJ_TAINT(str);*/
return str;
}
@@ -1902,7 +1891,6 @@ match_array(mrb_state *mrb, mrb_value match, int start)
mrb_value ary;
mrb_value target;
int i;
- /*int taint = OBJ_TAINTED(match);*/
match_check(mrb, match);
regs = RMATCH_REGS(match);
@@ -1915,7 +1903,6 @@ match_array(mrb_state *mrb, mrb_value match, int start)
}
else {
mrb_value str = mrb_str_subseq(mrb, target, regs->beg[i], regs->end[i]-regs->beg[i]);
- /*if (taint) OBJ_TAINT(str);*/
mrb_ary_push(mrb, ary, str);
}
}
@@ -2111,7 +2098,7 @@ mrb_reg_match_post(mrb_state *mrb, mrb_value match)
str = RMATCH(match)->str;
pos = END(0);
str = mrb_str_subseq(mrb, str, pos, RSTRING_LEN(str) - pos);
- /*if (OBJ_TAINTED(match)) OBJ_TAINT(str);*/
+
return str;
}
@@ -2138,7 +2125,7 @@ mrb_reg_match_pre(mrb_state *mrb, mrb_value match)
regs = RMATCH_REGS(match);
if (BEG(0) == -1) return mrb_nil_value();
str = mrb_str_subseq(mrb, RMATCH(match)->str, 0, BEG(0));
- /*if (OBJ_TAINTED(match)) OBJ_TAINT(str);*/
+
return str;
}
@@ -2207,8 +2194,7 @@ mrb_match_to_s(mrb_state *mrb, mrb_value match)
match_check(mrb, match);
if (mrb_nil_p(str)) str = mrb_str_new(mrb, 0, 0);//mrb_str_new(0,0);
- /*if (OBJ_TAINTED(match)) OBJ_TAINT(str); */
- /*if (OBJ_TAINTED(RMATCH(match)->str)) OBJ_TAINT(str); */
+
return str;
}
@@ -2436,7 +2422,6 @@ mrb_reg_to_s(mrb_state *mrb, mrb_value re)
mrb_str_buf_cat(mrb, str, ")", strlen(")"));
mrb_enc_copy(mrb, str, re);
- /*OBJ_INFECT(str, re);*/
return str;
}
View
@@ -19,10 +19,6 @@
#include <ieeefp.h>
#endif
-#ifndef MRB_TAINT_P
- #define MRB_TAINTED_P(p) FALSE
-#endif
-
#define BIT_DIGITS(N) (((N)*146)/485 + 1) /* log2(10) =~ 146/485 */
#define BITSPERDIG (sizeof(mrb_int)*CHAR_BIT)
#define EXTENDSIGN(n, l) (((~0 << (n)) >> (((n)*(l)) % BITSPERDIG)) & ~(~0 << (n)))
@@ -499,7 +495,6 @@ mrb_str_format(mrb_state *mrb, int argc, const mrb_value *argv, mrb_value fmt)
int width, prec, flags = FNONE;
int nextarg = 1;
int posarg = 0;
- int tainted = 0;
mrb_value nextvalue;
mrb_value tmp;
mrb_value str;
@@ -522,7 +517,6 @@ mrb_str_format(mrb_state *mrb, int argc, const mrb_value *argv, mrb_value fmt)
++argc;
--argv;
- if (MRB_TAINTED_P(fmt)) tainted = 1;
mrb_string_value(mrb, &fmt);
fmt = mrb_str_new4(mrb, fmt);
p = RSTRING_PTR(fmt);
@@ -726,7 +720,6 @@ mrb_str_format(mrb_state *mrb, int argc, const mrb_value *argv, mrb_value fmt)
if (*p == 'p') arg = mrb_inspect(mrb, arg);
str = mrb_obj_as_string(mrb, arg);
- if (MRB_TAINTED_P(str)) tainted = 1;
len = RSTRING_LEN(str);
mrb_str_set_len(mrb, result, blen);
if (flags&(FPREC|FWIDTH)) {
Oops, something went wrong.

0 comments on commit d4ef3ba

Please sign in to comment.