From e16f3f5668d29e34e60eb6026f3197f9b5bd872b Mon Sep 17 00:00:00 2001 From: GameHerobrine Date: Mon, 23 Feb 2026 22:44:43 +0300 Subject: [PATCH] readInt/Float/LDouble/LLong will return 0 if str has not enough bytes --- src/utils/Utils.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils/Utils.php b/src/utils/Utils.php index c4f4a1ee..66c36938 100644 --- a/src/utils/Utils.php +++ b/src/utils/Utils.php @@ -576,7 +576,7 @@ class Utils{ } public static function readInt($str){ - if(strlen($str) <= 0) return; + if(strlen($str) < 4) return 0; return @unpack("N", $str)[1] << 32 >> 32; //php has no signed long unpack } @@ -589,7 +589,8 @@ class Utils{ } public static function readFloat($str){ - list(, $value) = unpack("G", $str); + if(strlen($str) < 4) return 0; + list(, $value) = @unpack("G", $str); return $value; } @@ -611,6 +612,7 @@ class Utils{ } public static function readLDouble($str){ + if(strlen($str) < 8) return 0; list(, $value) = @unpack("e", $str); return $value; } @@ -620,6 +622,7 @@ class Utils{ } public static function readLLong($str){ + if(strlen($str) < 8) return 0; return unpack("P", $str)[1]; }