Skip to content

Commit

Permalink
- fix critical bag
Browse files Browse the repository at this point in the history
for func writeVStringLE \\n and \\r have to be in BE
  • Loading branch information
t3ran13 committed Oct 13, 2018
1 parent fa66f87 commit 4b7c490
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/t3ran13/ByteBuffer/ByteBuffer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 4b7c490

Please sign in to comment.