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 @@ -271,7 +271,8 @@ public function readTag()
271271 public function readRaw ($ size , &$ buffer )
272272 {
273273 $ current_buffer_size = 0 ;
274- if ($ this ->bufferSize () < $ size ) {
274+ // size (varint) read from the wire could be negative.
275+ if ($ size < 0 || $ this ->bufferSize () < $ size ) {
275276 return false ;
276277 }
277278
Original file line number Diff line number Diff line change @@ -603,6 +603,13 @@ public function testDecodeNegativeInt32()
603603 $ this ->assertEquals (-1 , $ m ->getOptionalInt32 ());
604604 }
605605
606+ public function testInvalidVarintLength () {
607+ $ this ->expectException (Exception::class);
608+
609+ $ m = new TestMessage ();
610+ $ m ->mergeFromString (hex2bin ("0afaffffff0f " ));
611+ }
612+
606613 private function makeRecursiveMessage ($ depth ) {
607614 $ m = new TestMessage ();
608615 $ m ->setOptionalInt32 (1 );
You can’t perform that action at this time.
0 commit comments