Commit Graph

17883 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto ec58dca22f mruby-array-ext: use Data_Make_Struct() in ary_combination_init
refactor to use the standard Data_Make_Struct() macro instead of manual
RData allocation and linking. the macro provides automatic zero-initialization
and is more idiomatic.

ref #6655

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-27 11:46:22 +09:00
Yukihiro "Matz" Matsumoto 16efbd5c91 Merge pull request #6655 from dearblue/combination_init 2025-10-27 11:43:26 +09:00
Yukihiro "Matz" Matsumoto ad51bf848b mrbgem.rake: simplify hal selection logic
remove redundant visualcpp and mingw checks since for_windows? already
detects all windows builds including visual c++ and mingw.

ref #6653

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-27 11:11:27 +09:00
Yukihiro "Matz" Matsumoto 28b567ae78 Merge pull request #6653 from dearblue/mingw
Improve HAL-related components for MinGW
2025-10-27 10:56:28 +09:00
Yukihiro "Matz" Matsumoto f1e2ab03fb ci: remove interactive claude workflow
removed due to same OIDC authentication failures as claude-code-review.
workflow can be re-added when the action is more stable.

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-27 09:01:43 +09:00
Yukihiro "Matz" Matsumoto 4220ab449c ci: remove claude code review workflow
removed due to persistent OIDC authentication failures in the beta action.
workflow can be re-added when the action is more stable.

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-27 08:58:42 +09:00
Yukihiro "Matz" Matsumoto 88bfa0bec1 mruby-bigint: move pool handling from bint_set to mpz_move
refactored the stack-use-after-return fix to encapsulate pool memory
handling in mpz_move instead of bint_set, providing cleaner code and
automatic protection for all 22 callers of mpz_move; ref #6651

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-27 08:48:04 +09:00
Yukihiro "Matz" Matsumoto 6e89c433a8 Merge pull request #6651 from meder/meder-patch-2 2025-10-27 08:43:17 +09:00
Yukihiro "Matz" Matsumoto 40606418a9 mruby-array-ext: combine variable declaration with initialization 2025-10-27 08:38:17 +09:00
Yukihiro "Matz" Matsumoto 8455c41a74 mruby-compiler: combine variable declaration with initialization 2025-10-27 08:24:07 +09:00
Yukihiro "Matz" Matsumoto b6eb21cac0 mruby-errno: combine variable declaration with initialization 2025-10-27 07:59:20 +09:00
Yukihiro "Matz" Matsumoto 3872587ec2 mruby-eval: combine variable declaration with initialization 2025-10-27 07:45:40 +09:00
Yukihiro "Matz" Matsumoto 5a147838ba mruby-hash-ext: combine variable declaration with initialization 2025-10-26 23:52:20 +09:00
Yukihiro "Matz" Matsumoto e636360250 mruby-io: combine variable declaration with initialization 2025-10-26 23:48:38 +09:00
Yukihiro "Matz" Matsumoto d81d343f5b mruby-math: combine variable declaration with initialization 2025-10-26 23:30:14 +09:00
Yukihiro "Matz" Matsumoto 4eddd18ebb mruby-pack: combine variable declaration with initialization 2025-10-26 23:03:47 +09:00
dearblue 2512b4b399 Preventing Memory Leaks in Array#__combination_init
If memory allocated with `mrb_malloc()` is not associated with an object, subsequent attempts to allocate memory or objects will fail and raise an exception, resulting in a memory leak.
2025-10-26 20:49:25 +09:00
Yukihiro "Matz" Matsumoto 87f406581b mruby-proc-ext: combine variable declaration with initialization 2025-10-26 20:33:06 +09:00
Yukihiro "Matz" Matsumoto 5d62acc3b8 mruby-sleep: combine variable declaration with initialization 2025-10-26 20:01:30 +09:00
Yukihiro "Matz" Matsumoto c1653debb1 mruby-socket: combine variable declaration with initialization 2025-10-26 20:00:04 +09:00
Yukihiro "Matz" Matsumoto 5b32cbf089 mruby-strftime: combine variable declaration with initialization 2025-10-26 19:16:12 +09:00
Yukihiro "Matz" Matsumoto f5cfb53b2e mruby-string-ext: combine variable declaration with initialization 2025-10-26 19:12:35 +09:00
Yukihiro "Matz" Matsumoto 19d545688d mruby-struct: combine variable declaration with initialization 2025-10-26 19:10:37 +09:00
Yukihiro "Matz" Matsumoto def463962e mruby-task: combine variable declaration with initialization 2025-10-26 19:05:01 +09:00
Yukihiro "Matz" Matsumoto 00e7474cce array.c: combine variable declaration with initialization 2025-10-25 23:27:08 +09:00
Yukihiro "Matz" Matsumoto 7eb6ca686c class.c: combine variable declaration with initialization 2025-10-25 23:14:52 +09:00
Yukihiro "Matz" Matsumoto f432f1772d dump.c: combine variable declaration with initialization 2025-10-25 23:10:24 +09:00
Yukihiro "Matz" Matsumoto 35f2e97d40 kernel.c: combine variable declaration with initialization 2025-10-25 22:37:31 +09:00
Yukihiro "Matz" Matsumoto d33aaecf39 numeric.c: combine variable declaration with initialization 2025-10-25 21:58:39 +09:00
dearblue ea215bc19c Fixed HAL auto-detection order
Because MinGW was not recognized as Windows during cross-builds.
2025-10-25 21:06:16 +09:00
dearblue 80e9105afb Explicitly include errno.h
This is required for `ENOSYS`.
2025-10-25 21:05:39 +09:00
dearblue e332b8e26e Define _WIN32_WINNT first
Some toolchains may define different default values.
2025-10-25 21:04:03 +09:00
Yukihiro "Matz" Matsumoto b171abade2 range.c: combine variable declaration with initialization 2025-10-25 19:48:14 +09:00
Yukihiro "Matz" Matsumoto 905bb7366b string.c: combine variable declaration with initialization 2025-10-25 15:50:41 +09:00
Yukihiro "Matz" Matsumoto 516d2bcc52 symbol.c: combine variable declaration with initialization 2025-10-25 15:39:32 +09:00
Yukihiro "Matz" Matsumoto 0211004cf2 variable.c: combine variable declaration with initialization 2025-10-25 09:36:48 +09:00
Yukihiro "Matz" Matsumoto 0bfc2164ed vm.c: combine variable declaration with initialization 2025-10-25 09:19:14 +09:00
Yukihiro "Matz" Matsumoto bd3b5f87fb mruby-array-ext: revert unsafe length caching in ary_intersect_p; ref #6652
both hash and linear paths cache array lengths before loops that call
mrb_eql() and mrb_equal(), which can execute user code that modifies
arrays, causing out-of-bounds access.

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-25 08:45:39 +09:00
Yukihiro "Matz" Matsumoto 56a0bdf493 mruby-array-ext: revert unsafe hash path hoisting; ref #6652
khash operations (kh_get, kh_put) call mrb_eql() which can execute user
code that modifies arrays during iteration, invalidating cached pointers
and lengths. reverted hoisting in ary_subtract_internal, ary_union_internal,
ary_intersection_internal, and ary_uniq_bang hash paths.

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-25 08:45:39 +09:00
Yukihiro "Matz" Matsumoto 2f4d3a329b partial revert "mruby-array-ext: hoist RARRAY_PTR calls outside loops"; ref #6652
revert hoisting in functions that call mrb_equal() which can execute user
code that modifies arrays during iteration causing use-after-free

reverted functions:
- ary_assoc, ary_rassoc: call mrb_equal()
- ary_subtract_internal (linear path): calls mrb_equal()
- ary_union_internal (linear path): calls add_uniq() -> mrb_equal()
- ary_intersection_internal (linear path): calls mrb_equal()
- ary_intersect_p (linear path): calls mrb_equal()
- ary_uniq_bang (linear path): calls mrb_equal()

kept optimizations in:
- ary_compact_bang: only checks mrb_nil_p(), no callbacks
- ary_rotate: only reads from self, no callbacks
- hash paths: use kh_get/kh_put, no Ruby callbacks

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-25 08:45:39 +09:00
Yukihiro "Matz" Matsumoto 12268dc3ef revert "array.c: hoist RARRAY_PTR calls in comparison operator"; fix #6652
this reverts commit 04af58db89 which caused use-after-free vulnerability.
cached array pointers become invalid when mrb_cmp() executes user's <=>
method that can modify arrays during iteration

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-25 08:39:01 +09:00
Meder Kydyraliev efd13872e4 Fix superfulous curly brackets 2025-10-23 21:17:36 +11:00
Yukihiro "Matz" Matsumoto b135601e6a mruby-array-ext: combine variable declaration with initialization
Co-authored-by: Claude <noreply@anthropic.com>
2025-10-23 15:28:25 +09:00
Meder Kydyraliev 49bc07d9a1 Address stack-use-after-return in the mruby bigint implementation.
The fix is to modify `bint_set` to ensure that the data stored in the persistent `RBigint` object is allocated on the heap if it's not embedded. We check if the source `mpz_t` uses memory from the stack pool using `is_pool_memory`. If it does, we must perform a deep copy (`mpz_set`) to allocate new heap memory and copy the data, instead of moving the pointer (`mpz_move`). If the source is already on the heap, we retain the efficient `mpz_move`.


OSS-Fuzz testcase: https://oss-fuzz.com/testcase-detail/5279371075321856
2025-10-23 16:23:52 +11:00
Yukihiro "Matz" Matsumoto 8c4bf04856 mruby-time: combine variable declaration with initialization
Co-authored-by: Claude <noreply@anthropic.com>
2025-10-23 13:55:47 +09:00
Yukihiro "Matz" Matsumoto d4d2955c6b mruby-sprintf: combine variable declarations with initialization
Co-authored-by: Claude <noreply@anthropic.com>
2025-10-23 13:35:44 +09:00
Yukihiro "Matz" Matsumoto 036b40e265 gc.c: combine variable declaration with initialization
Co-authored-by: Claude <noreply@anthropic.com>
2025-10-23 11:34:21 +09:00
Yukihiro "Matz" Matsumoto 93619f06dd mruby-array-ext: validate start and length in fill operation; fix #6650
add validation to prevent out-of-bounds write when negative start or
length bypasses normalization

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-23 11:03:11 +09:00
Yukihiro "Matz" Matsumoto dee72daf97 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>
2025-10-22 15:25:47 +09:00
Yukihiro "Matz" Matsumoto 01ab2ffc29 mruby-io: fix buffer overflow in io#ungetc; fix #6647
io_unget_data had two issues that caused crashes with repeated ungetc:

1. Integer underflow in buffer size check: "len > MRB_IO_BUF_SIZE - buf->len"
   could underflow when buf->len was large, bypassing reallocation

2. Short overflow: buf->len could exceed SHRT_MAX after multiple ungetc
   calls, causing integer overflow when cast to short

Fixed by checking buf->len + len against both MRB_IO_BUF_SIZE and
SHRT_MAX before buffer operations.

Co-authored-by: Claude <noreply@anthropic.com>
2025-10-22 14:04:14 +09:00