dep-protobuf/ruby/tests
vhulto f04511c9c2 Ruby: clamp len in RepeatedField#[beg, len] to fix out-of-bounds read (#27191)
## Bug

`RepeatedField_subarray` (called from `RepeatedField_index` 2-arg form,
`repeated_field.c:270`) loops `i` from `beg` to `beg + len` and calls
`upb_Array_Get(arr, i)` for every value. `upb_Array_Get` only has a
debug-only `UPB_ASSERT` (ruby-upb.c:7182); release builds therefore
perform `memcpy(&ret, data + (i << lg2), 1 << lg2)` for arbitrary `i`,
reading the upb arena out of bounds.

Result: silent heap info disclosure for numeric fields (`repeated int32`
returns adjacent arena bytes as Ruby integers), segfault for
`repeated string`/`message`. Confirmed with ASAN (`use-after-poison`,
READ size 4 at `RepeatedField_subarray:188`).

## Fix

Clamp `len` to `size - beg` in `RepeatedField_subarray`, matching Ruby
`Array#[beg, len]` semantics. Also reject negative `len` and fix the
`rb_ary_new2(size)` capacity hint to use the now-known `len`.

Closes #27191

COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/27191 from vhullto:fix/repeated-field-subarray-oob 876202835c
PiperOrigin-RevId: 917251509
2026-05-18 08:40:57 -07:00
..
basic.rb [Ruby]Implement #to_hash for message classes (#20866) 2025-03-28 19:18:16 -07:00
basic_proto2.rb Added a test that verifies existing enum behavior for Ruby. 2025-12-30 14:17:56 -08:00
basic_test.proto Implement edition 2023 support in all Ruby runtimes. 2024-03-15 15:17:33 -07:00
basic_test_features.proto Implement edition 2023 support in all Ruby runtimes. 2024-03-15 15:17:33 -07:00
basic_test_proto2.proto Implement edition 2023 support in all Ruby runtimes. 2024-03-15 15:17:33 -07:00
BUILD.bazel Fix silent failure of rb_test rules to run test (#21733) 2025-05-13 19:33:41 -07:00
common_tests.rb Update upb_Message_ShallowCopy to handle extensions and unknown fields. 2026-04-17 17:55:18 -07:00
encode_decode_test.rb Gracefully handle payloads >2GB. 2026-04-01 07:48:31 -07:00
gc_test.rb Remove codes for unsupported Ruby (#17353) 2024-08-01 14:02:45 -07:00
generated_code.proto Auto capitalize enums name in Ruby (#10454) 2022-09-28 16:32:16 -04:00
generated_code_editions.proto Implement edition 2023 support in all Ruby runtimes. 2024-03-15 15:17:33 -07:00
generated_code_proto2.proto Auto capitalize enums name in Ruby (#10454) 2022-09-28 16:32:16 -04:00
generated_code_proto2_test.rb Set execute bit on files if and only if they begin with (#!). (#7347) 2020-04-01 15:28:25 -07:00
generated_code_test.rb Implement edition 2023 support in all Ruby runtimes. 2024-03-15 15:17:33 -07:00
golden-ruby_ffi_bindings.txt Add UPB_NODISCARD in many places, prioritizing ones that use the return value to indicate an error 2026-04-20 14:07:50 -07:00
implementation.rb Ruby FFI implementation (#13343) 2023-07-24 23:17:47 -07:00
memory_test.rb Add some missing tests to the test setting of Bazel for Ruby (#19870) 2025-01-30 19:41:27 -08:00
multi_level_nesting_test.proto Make the new multi-level ruby tests fit the existing structure better and add them to the makefile 2021-01-14 12:26:04 -08:00
multi_level_nesting_test.rb Fix jruby support to handle messages nested more than 1 level deep 2021-01-14 12:26:04 -08:00
object_cache_test.rb Moved ObjectCache into an internal module. 2024-02-13 09:34:09 -08:00
repeated_field_test.proto Breaking Change: Dropped support for Ruby DSL, [as previously announced](https://engdoc.corp.google.com/eng/doc/devguide/proto/news/2023-12-27.md#ruby-breaking-changes). 2024-01-03 13:05:48 -08:00
repeated_field_test.rb Ruby: clamp len in RepeatedField#[beg, len] to fix out-of-bounds read (#27191) 2026-05-18 08:40:57 -07:00
ruby_version.rb Remove all autotools usage (#10132) 2022-08-10 22:51:29 -07:00
service_test.proto Implement service & method descriptor lookup in Ruby (#15817) 2024-03-22 10:35:56 -07:00
service_test.rb Add to_proto to descriptor classes (#19971) 2025-02-04 10:54:52 -08:00
stress.proto Fix separate issues in JRuby's "native" dup and inspect methods. (#15265) 2024-01-05 10:41:01 -08:00
stress.rb Fix separate issues in JRuby's "native" dup and inspect methods. (#15265) 2024-01-05 10:41:01 -08:00
test_import.proto Added unit test for PascalCasing package names in Ruby. 2016-07-25 15:16:23 -07:00
test_import_proto2.proto Adds support for proto2 syntax for Ruby gem. 2018-09-27 14:21:16 -04:00
test_ruby_package.proto Fix Ruby module name generation when the ruby_package option is used (again) (#5794) 2019-03-02 10:38:10 -08:00
test_ruby_package_proto2.proto Fix Ruby module name generation when the ruby_package option is used (again) (#5794) 2019-03-02 10:38:10 -08:00
type_errors.rb Updated Ruby min version to 2.7, and removed some compat code 2023-07-11 11:32:03 -07:00
utf8.proto [Ruby] Warn if assigning a "UTF-8" string with invalid UTF-8. (#17253) 2024-07-17 08:15:14 -07:00
utf8.rb Error if assigning a "UTF-8" string with invalid UTF-8. 2024-10-31 13:47:55 -07:00
well_known_types_test.rb Bulk update to use assert_* methods wherever possible. (#13156) 2023-06-28 20:31:32 -07:00