File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
src/Google/Protobuf/Internal Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -338,7 +338,7 @@ public function incrementRecursionDepthAndPushLimit(
338338 $ byte_limit , &$ old_limit , &$ recursion_budget )
339339 {
340340 $ old_limit = $ this ->pushLimit ($ byte_limit );
341- $ recursion_limit = --$ this ->recursion_limit ;
341+ $ recursion_budget = --$ this ->recursion_budget ;
342342 }
343343
344344 public function decrementRecursionDepthAndPopLimit ($ byte_limit )
Original file line number Diff line number Diff line change @@ -610,6 +610,31 @@ public function testInvalidVarintLength() {
610610 $ m ->mergeFromString (hex2bin ("0afaffffff0f " ));
611611 }
612612
613+ private function makeRecursiveMessage ($ depth ) {
614+ $ m = new TestMessage ();
615+ $ m ->setOptionalInt32 (1 );
616+ if ($ depth == 0 ) {
617+ return $ m ;
618+ }
619+ $ m ->setRecursive ($ this ->makeRecursiveMessage ($ depth - 1 ));
620+ return $ m ;
621+ }
622+
623+ public function testRecursiveMessage () {
624+ $ payload = $ this ->makeRecursiveMessage (99 )->serializeToString ();
625+
626+ $ m = new TestMessage ();
627+ $ m ->mergeFromString ($ payload );
628+ }
629+
630+ public function testOverlyRecursiveMessage () {
631+ $ this ->expectException (Exception::class);
632+ $ payload = $ this ->makeRecursiveMessage (101 )->serializeToString ();
633+
634+ $ m = new TestMessage ();
635+ $ m ->mergeFromString ($ payload );
636+ }
637+
613638 public function testRandomFieldOrder ()
614639 {
615640 $ m = new TestRandomFieldOrder ();
You can’t perform that action at this time.
0 commit comments