mruby-sprintf: prevent buffer overread in named format parsing; fix #6648

add bounds check at retry label to prevent reading past end of format string
when parsing unterminated named parameters like %<foo without closing >

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-10-22 15:25:47 +09:00
parent 01ab2ffc29
commit dee72daf97
+3
View File
@@ -413,6 +413,9 @@ mrb_str_format(mrb_state *mrb, mrb_int argc, const mrb_value *argv, mrb_value fm
nextvalue = mrb_undef_value();
retry:
if (p >= end) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "malformed format string - unexpected end");
}
{
fmt_spec_t spec = get_format_info(*p);