File tree Expand file tree Collapse file tree
src/Google/Protobuf/Internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -337,7 +337,7 @@ public function incrementRecursionDepthAndPushLimit(
337337 $ byte_limit , &$ old_limit , &$ recursion_budget )
338338 {
339339 $ old_limit = $ this ->pushLimit ($ byte_limit );
340- $ recursion_limit = --$ this ->recursion_limit ;
340+ $ recursion_budget = --$ this ->recursion_budget ;
341341 }
342342
343343 public function decrementRecursionDepthAndPopLimit ($ byte_limit )
Original file line number Diff line number Diff line change @@ -603,6 +603,31 @@ public function testDecodeNegativeInt32()
603603 $ this ->assertEquals (-1 , $ m ->getOptionalInt32 ());
604604 }
605605
606+ private function makeRecursiveMessage ($ depth ) {
607+ $ m = new TestMessage ();
608+ $ m ->setOptionalInt32 (1 );
609+ if ($ depth == 0 ) {
610+ return $ m ;
611+ }
612+ $ m ->setRecursive ($ this ->makeRecursiveMessage ($ depth - 1 ));
613+ return $ m ;
614+ }
615+
616+ public function testRecursiveMessage () {
617+ $ payload = $ this ->makeRecursiveMessage (99 )->serializeToString ();
618+
619+ $ m = new TestMessage ();
620+ $ m ->mergeFromString ($ payload );
621+ }
622+
623+ public function testOverlyRecursiveMessage () {
624+ $ this ->expectException (Exception::class);
625+ $ payload = $ this ->makeRecursiveMessage (101 )->serializeToString ();
626+
627+ $ m = new TestMessage ();
628+ $ m ->mergeFromString ($ payload );
629+ }
630+
606631 public function testRandomFieldOrder ()
607632 {
608633 $ m = new TestRandomFieldOrder ();
You can’t perform that action at this time.
0 commit comments