mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
variable.c (mrb_exc_const_get): E_XXX_ERROR should not call const_missing
As #6359 pointed out, calling const_missing hook from E_XXX_ERROR (that calls mrb_exc_get_id()) can be an attack vector. Since E_XXX_ERROR is supposed to be a defined error class, we think that the situation where it is undefined and the const_missing hook is called should be detected as an error; fix #6359
This commit is contained in:
+4
-2
@@ -659,7 +659,7 @@ mrb_class_get_id(mrb_state *mrb, mrb_sym name)
|
||||
MRB_API struct RClass*
|
||||
mrb_exc_get_id(mrb_state *mrb, mrb_sym name)
|
||||
{
|
||||
mrb_value c = mrb_const_get(mrb, mrb_obj_value(mrb->object_class), name);
|
||||
mrb_value c = mrb_exc_const_get(mrb, name);
|
||||
|
||||
if (!mrb_class_p(c)) {
|
||||
mrb_raise(mrb, E_EXCEPTION, "exception corrupted");
|
||||
@@ -670,7 +670,9 @@ mrb_exc_get_id(mrb_state *mrb, mrb_sym name)
|
||||
if (e == E_EXCEPTION)
|
||||
return exc;
|
||||
}
|
||||
return E_EXCEPTION;
|
||||
mrb_raise(mrb, E_EXCEPTION, "non-exception raised");
|
||||
/* not reached */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
MRB_API struct RClass*
|
||||
|
||||
Reference in New Issue
Block a user