pmmp / binaryutils Goto Github PK
View Code? Open in Web Editor NEWPHP library containing classes and methods for conveniently handling binary strings
License: GNU Lesser General Public License v3.0
PHP library containing classes and methods for conveniently handling binary strings
License: GNU Lesser General Public License v3.0
$buf = new \pocketmine\utils\BinaryStream("\x80\x80\x80\x80\x80\x01");
var_dump($buf->getUnsignedVarInt());
This code should throw an exception because there is a 6-byte varint in the buffer, but it does not.
Currently trying to read past the end of available data will cause lots of strange behaviour to occur. This should be explicitly checked instead of returning partial data or returning the wrong type of data (bool instead of string).
A lot of types are missing signed vs unsigned readers, and it isn't clear whether the existing methods return signed or unsigned values in a lot of cases. This is a problem because wrong values may be retrieved when reading userdata.
This bug was discovered during a bruteforce debugging test of packets.
When Binary::readUnsignedVarInt()
or Binary::readUnsignedVarLong()
receives a buffer with an offset which points at somewhere outside of the buffer, an E_NOTICE is triggered due to Uninitialized string offset
. This read results in an empty string, which ord()
happily swallows and yields 0
from.
This should instead be throwing an OutOfBoundsException
when such behaviour occurs.
$stream = new \pocketmine\utils\BinaryStream();
$stream->setBuffer("", 1);
$stream->getRemaining();
Fatal error: Uncaught TypeError: Return value of pocketmine\utils\BinaryStream::getRemaining() must be of the type string, boolean returned
The current code accepts any non-zero value for true
and 0 for false
, but if a value outside of the range 0-1 is encountered, it most likely indicates corrupted data or broken code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.