From 4b7c4905019bb57d6fd9c541ff22bb53ef9f5fd9 Mon Sep 17 00:00:00 2001 From: t3ran13 Date: Sat, 13 Oct 2018 20:32:22 +0300 Subject: [PATCH] - fix critical bag for func writeVStringLE \\n and \\r have to be in BE --- src/t3ran13/ByteBuffer/ByteBuffer.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/t3ran13/ByteBuffer/ByteBuffer.php b/src/t3ran13/ByteBuffer/ByteBuffer.php index f87f14c..e0376ba 100644 --- a/src/t3ran13/ByteBuffer/ByteBuffer.php +++ b/src/t3ran13/ByteBuffer/ByteBuffer.php @@ -134,7 +134,11 @@ public function writeVStringLE($value, $offset = null) { $bytes = unpack('C*', $value); //string to bytes in int $total = count($bytes); for ($i = 0; $i < $total; $i++) { - $this->buffer[$offset++] = pack('H*', base_convert($bytes[$i+1], 10, 16)); + if (in_array($value[$i], ["\n","\r"])) { + $this->buffer[$offset++] = pack('h*', base_convert($bytes[$i+1], 10, 16)); + } else { + $this->buffer[$offset++] = pack('H*', base_convert($bytes[$i+1], 10, 16)); + } } $this->currentOffset = $offset; }