diff options
| author | Joe Bolinger <jbolinger@google.com> | 2019-02-27 20:26:14 -0800 |
|---|---|---|
| committer | Paul Yang <TeBoring@users.noreply.github.com> | 2019-02-27 20:26:14 -0800 |
| commit | 7f14ea9f48f21ce3c1528da56a3f101492324f45 (patch) | |
| tree | 6ae7fb396dbf7d15605642f02d769d785c44d127 /ruby/ext/google | |
| parent | e780681e35cbd1b3f329ee7b154b8e596680987a (diff) | |
| download | platform_external_protobuf-7f14ea9f48f21ce3c1528da56a3f101492324f45.tar.gz platform_external_protobuf-7f14ea9f48f21ce3c1528da56a3f101492324f45.tar.bz2 platform_external_protobuf-7f14ea9f48f21ce3c1528da56a3f101492324f45.zip | |
Raise error for JSON overflow encoding in Ruby (#5752)
* add check for overflow
* de-nestify
* break long lines
Diffstat (limited to 'ruby/ext/google')
| -rw-r--r-- | ruby/ext/google/protobuf_c/encode_decode.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/ruby/ext/google/protobuf_c/encode_decode.c b/ruby/ext/google/protobuf_c/encode_decode.c index c5078bcb7..5ead9b898 100644 --- a/ruby/ext/google/protobuf_c/encode_decode.c +++ b/ruby/ext/google/protobuf_c/encode_decode.c @@ -1061,6 +1061,11 @@ static void put_ruby_value(VALUE value, upb_sink *sink, bool emit_defaults, bool is_json) { + if (depth > ENCODE_MAX_NESTING) { + rb_raise(rb_eRuntimeError, + "Maximum recursion depth exceeded during encoding."); + } + upb_selector_t sel = 0; if (upb_fielddef_isprimitive(f)) { sel = getsel(f, upb_handlers_getprimitivehandlertype(f)); |
