Commit d4ef3bac authored by Yukihiro Matsumoto's avatar Yukihiro Matsumoto

remove code for unsupported taint-mode

parent 1605ec8c
......@@ -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;
......
......@@ -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;
}
......
......@@ -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
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -189,7 +189,7 @@ meta_found:
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 @@ again:
mrb_str_buf_cat(mrb, str, ")", strlen(")"));
mrb_enc_copy(mrb, str, re);
/*OBJ_INFECT(str, re);*/
return str;
}
......
......@@ -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 @@ format_s:
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)) {
......
......@@ -81,14 +81,6 @@ mrb_str_set_len(mrb_state *mrb, mrb_value str, long len)
static mrb_value mrb_enc_cr_str_buf_cat(mrb_state *mrb, mrb_value str, const char *ptr, long len,
int ptr_encindex, int ptr_cr, int *ptr_cr_ret);
#endif //INCLUDE_ENCODING
mrb_value
mrb_tainted_str_new(mrb_state *mrb, const char *ptr, long len)
{
mrb_value str = mrb_str_new(mrb, ptr, len);
//OBJ_TAINT(str);
return str;
}
#ifdef INCLUDE_ENCODING
mrb_value
......@@ -104,7 +96,7 @@ mrb_external_str_new_with_enc(mrb_state *mrb, const char *ptr, long len, mrb_enc
{
mrb_value str;
str = mrb_tainted_str_new(mrb, ptr, len);
str = mrb_str_new(mrb, ptr, len);
if (eenc == mrb_usascii_encoding(mrb) &&
mrb_enc_str_coderange(mrb, str) != ENC_CODERANGE_7BIT) {
mrb_enc_associate(mrb, str, mrb_ascii8bit_encoding(mrb));
......@@ -797,8 +789,6 @@ mrb_str_plus_m(mrb_state *mrb, mrb_value self)
RSTRING_PTR(str2), RSTRING_LEN(str2));
RSTRING_PTR(str3)[RSTRING_LEN(str3)] = '\0';
#ifdef INCLUDE_ENCODING
//if (OBJ_TAINTED(str1) || OBJ_TAINTED(str2))
// OBJ_TAINT(str3);
ENCODING_CODERANGE_SET(mrb, str3, mrb_enc_to_index(enc),
ENC_CODERANGE_AND(ENC_CODERANGE(self), ENC_CODERANGE(str2)));
#endif //INCLUDE_ENCODING
......@@ -889,7 +879,6 @@ mrb_str_times(mrb_state *mrb, mrb_value self)
}
ptr2[RSTRING_LEN(str2)] = '\0';
//OBJ_INFECT(str2, str);
mrb_enc_cr_str_copy_for_substr(mrb, str2, self);
return str2;
......@@ -1504,7 +1493,6 @@ num_index:
return mrb_nil_value();
default:
tmp = mrb_str_substr(mrb, str, beg, len);
/*OBJ_INFECT(tmp, indx);*/
return tmp;
}
}
......@@ -2106,7 +2094,6 @@ mrb_str_each_line(mrb_state *mrb, mrb_value str)
(rslen <= 1 ||
memcmp(prs->buf, p-rslen, rslen) == 0)) {
line = mrb_str_new5(mrb, str, s, p - s);
/*OBJ_INFECT(line, str);*/
mrb_yield(mrb, b, line);
str_mod_check(mrb, str, ptr, len);
s = p;
......@@ -2116,7 +2103,6 @@ mrb_str_each_line(mrb_state *mrb, mrb_value str)
if (s != pend) {
if (p > pend) p = pend;
line = mrb_str_new5(mrb, str, s, p - s);
/*OBJ_INFECT(line, str);*/
mrb_yield(mrb, b, line);
}
......@@ -2224,7 +2210,6 @@ mrb_str_new_shared(mrb_state *mrb, mrb_value str)
{
mrb_value str2 = str_new3(mrb, mrb_obj_class(mrb, str), str);
//OBJ_INFECT(str2, str);
return str2;
}
......@@ -2411,7 +2396,6 @@ mrb_str_buf_append(mrb_state *mrb, mrb_value str, mrb_value str2)
mrb_enc_cr_str_buf_cat(mrb, str, RSTRING_PTR(str2), RSTRING_LEN(str2),
ENCODING_GET(mrb, str2), str2_cr, &str2_cr);
//OBJ_INFECT(str, str2);
ENC_CODERANGE_SET(str2, str2_cr);
return str;
......@@ -2474,7 +2458,6 @@ str_gsub(mrb_state *mrb, mrb_value str, mrb_int bang)
mrb_int offset, blen, slen, len, last;
int iter = 0;
char *sp, *cp;
//int tainted = 0;
mrb_encoding *str_enc;
mrb_get_args(mrb, "*", &argv, &argc);
......@@ -2486,7 +2469,6 @@ str_gsub(mrb_state *mrb, mrb_value str, mrb_int bang)
case 2:
repl = argv[1];
mrb_string_value(mrb, &repl);
/*if (OBJ_TAINTED(repl)) tainted = 1;*/
break;
default:
mrb_raise(mrb, E_ARGUMENT_ERROR, "wrong number of arguments (%d for 2)", argc);
......@@ -2578,9 +2560,6 @@ str_gsub(mrb_state *mrb, mrb_value str, mrb_int bang)
* <code>$&</code>, and <code>$'</code> will be set appropriately. The value
* returned by the block will be substituted for the match on each call.
*
* The result inherits any tainting in the original string or any supplied
* replacement string.
*
* When neither a block nor a second argument is supplied, an
* <code>Enumerator</code> is returned.
*
......@@ -2818,9 +2797,6 @@ str_replace(mrb_state *mrb, mrb_value str, mrb_value str2)
* call-seq:
* str.replace(other_str) => str
*
* Replaces the contents and taintedness of <i>str</i> with the corresponding
* values in <i>other_str</i>.
*
* s = "hello" #=> "hello"
* s.replace "world" #=> "world"
*/
......@@ -3775,8 +3751,6 @@ mrb_str_sub_bang(mrb_state *mrb, mrb_value str)
}
mrb_str_modify(mrb, str);
mrb_enc_associate(mrb, str, enc);
//if (OBJ_TAINTED(repl)) tainted = 1;
//if (OBJ_UNTRUSTED(repl)) untrusted = 1;
if (ENC_CODERANGE_UNKNOWN < cr && cr < ENC_CODERANGE_BROKEN) {
int cr2 = ENC_CODERANGE(repl);
if (cr2 == ENC_CODERANGE_BROKEN ||
......@@ -3838,9 +3812,6 @@ mrb_str_sub_bang(mrb_state *mrb, mrb_value str)
* <code>$&</code>, and <code>$'</code> will be set appropriately. The value
* returned by the block will be substituted for the match on each call.
*
* The result inherits any tainting in the original string or any supplied
* replacement string.
*
* "hello".sub(/[aeiou]/, '*') #=> "h*llo"
* "hello".sub(/([aeiou])/, '<\1>') #=> "h<e>llo"
* "hello".sub(/./) {|s| s.ord.to_s + ' ' } #=> "104 ello"
......@@ -4703,7 +4674,6 @@ mrb_str_dump(mrb_state *mrb, mrb_value str)
snprintf(q, qend-q, ".force_encoding(\"%s\")", enc->name);
enc = mrb_ascii8bit_encoding(mrb);
}
//OBJ_INFECT(result, str);
/* result from dump is ASCII */
mrb_enc_associate(mrb, result, enc);
ENC_CODERANGE_SET(result, ENC_CODERANGE_7BIT);
......@@ -4792,7 +4762,7 @@ mrb_str_append(mrb_state *mrb, mrb_value str, mrb_value str2)
RSTRING(str)->len = len;
mrb_enc_associate(mrb, str, enc);
ENC_CODERANGE_SET(str, cr);
//OBJ_INFECT(str, str2);
return str;
}
#ifdef INCLUDE_ENCODING
......@@ -4989,7 +4959,6 @@ mrb_str_inspect(mrb_state *mrb, mrb_value str)
if (p > prev) mrb_str_buf_cat(mrb, result, prev, p - prev);
mrb_str_buf_cat(mrb, result, "\"", strlen("\"")); //str_buf_cat2(result, "\"");
//OBJ_INFECT(result, str);
return result;
}
......
......@@ -512,7 +512,6 @@ inspect_struct(mrb_state *mrb, mrb_value s, mrb_value dummy, int recur)
mrb_str_append(mrb, str, mrb_inspect(mrb, ptr[i]));
}
mrb_str_cat2(mrb, str, ">");
//OBJ_INFECT(str, s);
return str;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment