Skip to content

Commit 4b7c490

Browse files
committed
- fix critical bag
for func writeVStringLE \\n and \\r have to be in BE
1 parent fa66f87 commit 4b7c490

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/t3ran13/ByteBuffer/ByteBuffer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@ public function writeVStringLE($value, $offset = null) {
134134
$bytes = unpack('C*', $value); //string to bytes in int
135135
$total = count($bytes);
136136
for ($i = 0; $i < $total; $i++) {
137-
$this->buffer[$offset++] = pack('H*', base_convert($bytes[$i+1], 10, 16));
137+
if (in_array($value[$i], ["\n","\r"])) {
138+
$this->buffer[$offset++] = pack('h*', base_convert($bytes[$i+1], 10, 16));
139+
} else {
140+
$this->buffer[$offset++] = pack('H*', base_convert($bytes[$i+1], 10, 16));
141+
}
138142
}
139143
$this->currentOffset = $offset;
140144
}

0 commit comments

Comments
 (0)