php-mysql-replication icon indicating copy to clipboard operation
php-mysql-replication copied to clipboard

Big/little endian assumptions.

Open bbkr opened this issue 7 years ago • 0 comments

Following code https://github.com/krowinski/php-mysql-replication/blob/master/src/MySQLReplication/BinaryDataReader/BinaryDataReader.php#L72 works by accident because s uses native architecture. And every Intel/AMD CPU is in little endian architecture which is the same as binlog bytes layout.

Architecture should be forced in unpack pattern ( s< - like in Perl, I'm not sure if PHP supports it). Or native architecture should be checked and bytes reversed before unpacking in case of mismatch.

bbkr avatar Jun 06 '18 10:06 bbkr