diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-09-07 07:35:35 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-09-07 07:35:35 +0900 |
| commit | 711f06a562117c63b5b7b04f79d3c4a6b076b098 (patch) | |
| tree | 3f1e91c3d68ad2770ee3a18e1f3e7c5832f34b8a /mrbgems/mruby-eval/src/eval.c | |
| parent | 6fc6880f1fa84991e6b4d7e9b961d34568835dd5 (diff) | |
| download | mruby-711f06a562117c63b5b7b04f79d3c4a6b076b098.tar.gz mruby-711f06a562117c63b5b7b04f79d3c4a6b076b098.zip | |
eval.c: check length of the file name.
It should be lexx than `UINT16_MAX`. If you don't check here, the parser
would raise an exception.
Diffstat (limited to 'mrbgems/mruby-eval/src/eval.c')
| -rw-r--r-- | mrbgems/mruby-eval/src/eval.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/mrbgems/mruby-eval/src/eval.c b/mrbgems/mruby-eval/src/eval.c index b10e0c7ce..a3c421f45 100644 --- a/mrbgems/mruby-eval/src/eval.c +++ b/mrbgems/mruby-eval/src/eval.c @@ -52,10 +52,19 @@ create_proc_from_string(mrb_state *mrb, const char *s, mrb_int len, mrb_value bi e = NULL; } + if (file) { + if (strlen(file) >= UINT16_MAX) { + mrb_raise(mrb, E_ARGUMENT_ERROR, "filename too long"); + } + } + else { + file = "(eval)"; + } + cxt = mrbc_context_new(mrb); cxt->lineno = (uint16_t)line; - mrbc_filename(mrb, cxt, file ? file : "(eval)"); + mrbc_filename(mrb, cxt, file); cxt->capture_errors = TRUE; cxt->no_optimize = TRUE; cxt->upper = scope && MRB_PROC_CFUNC_P(scope) ? NULL : scope; |
