File tree 1 file changed +13
-5
lines changed
1 file changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -20,15 +20,23 @@ class Factory
20
20
*/
21
21
public static function getNextPacket (Version $ version , $ remainingData )
22
22
{
23
- while (isset ($ remainingData [1 ])) {
23
+ while (isset ($ remainingData [1 ])) {
24
24
$ byte = 1 ;
25
- $ packetLength = 0 ;
25
+ $ remainingLength = 0 ;
26
+ $ multiplier = 1 ;
26
27
do {
28
+ if ($ byte >= 6 ) {
29
+ break ;
30
+ }
31
+
27
32
$ digit = ord ($ remainingData [$ byte ]);
28
- $ packetLength += $ digit ;
33
+ $ remainingLength += ($ digit & 127 ) * $ multiplier ;
34
+ $ multiplier *= 128 ;
29
35
$ byte ++;
30
- } while (($ digit & 128 ) != 0 );
31
- $ packetLength += 2 ;
36
+ } while (($ digit & 128 ) !== 0 );
37
+
38
+ $ packetLength = $ byte + $ remainingLength ;
39
+
32
40
$ nextPacketData = substr ($ remainingData , 0 , $ packetLength );
33
41
$ remainingData = substr ($ remainingData , $ packetLength );
34
42
You can’t perform that action at this time.
0 commit comments