Bug #11386 » 0001-string.c-keep-taintedness.patch
string.c | ||
---|---|---|
}
|
||
static int fstring_cmp(VALUE a, VALUE b);
|
||
static st_index_t fstring_hash(VALUE str);
|
||
/* in case we restart MVM development, this needs to be per-VM */
|
||
static st_table* frozen_strings;
|
||
... | ... | |
static const struct st_hash_type fstring_hash_type = {
|
||
fstring_cmp,
|
||
rb_str_hash,
|
||
fstring_hash,
|
||
};
|
||
static int
|
||
... | ... | |
}
|
||
else {
|
||
if (STR_SHARED_P(str)) { /* str should not be shared */
|
||
const int taint = RBASIC(str)->flags & FL_TAINT;
|
||
str = rb_enc_str_new(RSTRING_PTR(str), RSTRING_LEN(str), STR_ENC_GET(str));
|
||
OBJ_FREEZE(str);
|
||
RBASIC(str)->flags |= FL_FREEZE | taint;
|
||
}
|
||
else {
|
||
str = rb_str_new_frozen(str);
|
||
... | ... | |
static int
|
||
fstring_cmp(VALUE a, VALUE b)
|
||
{
|
||
int cmp = rb_str_hash_cmp(a, b);
|
||
int cmp;
|
||
cmp = FL_TEST_RAW(b, FL_TAINT) - FL_TEST_RAW(a, FL_TAINT);
|
||
if (cmp != 0) {
|
||
return cmp;
|
||
}
|
||
cmp = rb_str_hash_cmp(a, b);
|
||
if (cmp != 0) {
|
||
return cmp;
|
||
}
|
||
return ENCODING_GET(b) - ENCODING_GET(a);
|
||
}
|
||
static st_index_t
|
||
fstring_hash(VALUE str)
|
||
{
|
||
int e = ENCODING_GET(str);
|
||
if (e && rb_enc_str_coderange(str) == ENC_CODERANGE_7BIT) {
|
||
e = 0;
|
||
}
|
||
e ^= FL_TEST_RAW(str, FL_TAINT);
|
||
return rb_memhash((const void *)RSTRING_PTR(str), RSTRING_LEN(str)) ^ e;
|
||
}
|
||
static inline int
|
||
single_byte_optimizable(VALUE str)
|
||
{
|