зеркало из https://github.com/github/ruby.git
ensure ibf_load_setup is only passed String params
In cases where RubyVM::InstructionSequence.load_from_binary() is passed a param other than a String, we attempt to call the RSTRING_LENINT macro on it which can cause a segfault. ex: ``` var_0 = 0 RubyVM::InstructionSequence.load_from_binary(var_0) ``` This commit adds a type check to raise unless we are provided a String.
This commit is contained in:
Родитель
23be6599a2
Коммит
9555a997ac
|
@ -14214,6 +14214,8 @@ ibf_load_setup_bytes(struct ibf_load *load, VALUE loader_obj, const char *bytes,
|
|||
static void
|
||||
ibf_load_setup(struct ibf_load *load, VALUE loader_obj, VALUE str)
|
||||
{
|
||||
StringValue(str);
|
||||
|
||||
if (RSTRING_LENINT(str) < (int)sizeof(struct ibf_header)) {
|
||||
rb_raise(rb_eRuntimeError, "broken binary format");
|
||||
}
|
||||
|
|
|
@ -850,4 +850,11 @@ class TestISeq < Test::Unit::TestCase
|
|||
RubyVM::InstructionSequence.compile_prism(Object.new)
|
||||
end
|
||||
end
|
||||
|
||||
def test_load_from_binary_only_accepts_string_param
|
||||
assert_raise(TypeError) do
|
||||
var_0 = 0
|
||||
RubyVM::InstructionSequence.load_from_binary(var_0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче