@@ -4838,6 +4838,27 @@ public function testSerializerIGBinary() {
48384838 $ this ->redis ->setOption (Redis::OPT_PREFIX , "test: " );
48394839 $ this ->checkSerializer (Redis::SERIALIZER_IGBINARY );
48404840 $ this ->redis ->setOption (Redis::OPT_PREFIX , "" );
4841+
4842+ /* Test our igbinary header check logic. The check allows us to do
4843+ simple INCR type operations even with the serializer enabled, and
4844+ should also protect against igbinary-like data from being erroneously
4845+ deserialized */
4846+ $ this ->redis ->del ('incrkey ' );
4847+
4848+ $ this ->redis ->set ('spoof-1 ' , "\x00\x00\x00\x00" );
4849+ $ this ->redis ->set ('spoof-2 ' , "\x00\x00\x00\x00bad-version1 " );
4850+ $ this ->redis ->set ('spoof-3 ' , "\x00\x00\x00\x05bad-version2 " );
4851+ $ this ->redis ->setOption (Redis::OPT_SERIALIZER , Redis::SERIALIZER_IGBINARY );
4852+
4853+ $ this ->assertEquals (16 , $ this ->redis ->incrby ('incrkey ' , 16 ));
4854+ $ this ->assertEquals ('16 ' , $ this ->redis ->get ('incrkey ' ));
4855+
4856+ $ this ->assertEquals ("\x00\x00\x00\x00" , $ this ->redis ->get ('spoof-1 ' ));
4857+ $ this ->assertEquals ("\x00\x00\x00\x00bad-version1 " , $ this ->redis ->get ('spoof-2 ' ));
4858+ $ this ->assertEquals ("\x00\x00\x00\x05bad-version2 " , $ this ->redis ->get ('spoof-3 ' ));
4859+ $ this ->redis ->setOption (Redis::OPT_SERIALIZER , Redis::SERIALIZER_NONE );
4860+
4861+ $ this ->redis ->del ('incrkey ' , 'spoof-1 ' , 'spoof-2 ' , 'spoof-3 ' );
48414862 }
48424863 }
48434864
0 commit comments