fix: in bindings/ruby/test/jfk_reader/jfk_reader in jfk_reader.c#3756
fix: in bindings/ruby/test/jfk_reader/jfk_reader in jfk_reader.c#3756orbisai0security wants to merge 4 commits intoggml-org:masterfrom
Conversation
Automated security fix generated by Orbis Security AI
|
Thank you for finding the issue! Can you use allocator and free functions Ruby provides? |
|
Yes, good call. I can switch this over to Ruby’s alloc/free helpers (e.g. RB_ZALLOC_N/RB_ALLOC_N + xfree, or ruby_xcalloc + ruby_xfree) so we’re not mixing allocators. Let me know which style you prefer, and I’ll update the PR. |
|
I don't have strong opinion because I'm not familiar with Ruby extension development custom. |
|
Ah, sorry, I have seen only the diff lines, but I have a question now. Can an attacker control |
|
|
- Replace calloc/free with ALLOC_N/xfree to match Ruby binding conventions (ALLOC_N handles overflow checking and raises NoMemoryError on failure) - Free temporary samples buffer after conversion loop (was leaked) - Add NULL check for fopen return value with rb_raise - Add comment clarifying n_samples is a compile-time constant Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Thank you for the addressing. One more question: is it allowed to raise an exception in |
rb_memory_view_get_func_t callbacks should communicate errors via return value (false), not exceptions. rb_memory_view_get has no exception-handling wrapper around get_func calls. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
It is allowed but not safe to raise an exception in |
|
I found out that |
|
I have switched from |
|
Thank you for a lot of work! |
|
@ggerganov @danbev |
Summary
Fix critical severity security issue in
bindings/ruby/test/jfk_reader/jfk_reader.c.Vulnerability
V-002bindings/ruby/test/jfk_reader/jfk_reader.c:18Description: In bindings/ruby/test/jfk_reader/jfk_reader.c at lines 18-19, malloc is called with n_samples * sizeof(float) and n_samples * sizeof(short) without any integer overflow check. If n_samples is attacker-controlled and close to SIZE_MAX/sizeof(float), the multiplication wraps around to a small value, causing malloc to allocate an undersized buffer. Subsequent writes of the full sample data overflow this buffer, corrupting heap memory.
Changes
bindings/ruby/test/jfk_reader/jfk_reader.cVerification
Automated security fix by OrbisAI Security