mirror of
https://github.com/zoriya/flood.git
synced 2025-12-06 07:16:18 +00:00
fix: correct buffers concatenation in socket (#787)
This commit is contained in:
@@ -126,15 +126,18 @@ class ClientRequestManager {
|
|||||||
tlsSocket.on('secureConnect', () => {
|
tlsSocket.on('secureConnect', () => {
|
||||||
tlsSocket.on('data', (chunk: Buffer) => {
|
tlsSocket.on('data', (chunk: Buffer) => {
|
||||||
if (rpcBuffer != null) {
|
if (rpcBuffer != null) {
|
||||||
rpcBuffer = Buffer.concat([rpcBuffer, chunk], rpcBufferSize);
|
rpcBuffer = Buffer.concat(
|
||||||
|
[rpcBuffer, chunk],
|
||||||
|
rpcBufferSize <= rpcBuffer.length + chunk.length ? rpcBufferSize : undefined,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
if (chunk[0] !== DELUGE_RPC_PROTOCOL_VERSION) {
|
if (chunk[0] !== DELUGE_RPC_PROTOCOL_VERSION) {
|
||||||
handleError(new Error('Unexpected Deluge RPC version.'));
|
handleError(new Error('Unexpected Deluge RPC version.'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
rpcBufferSize = chunk.slice(1, 5).readUInt32BE(0);
|
rpcBufferSize = chunk.subarray(1, 5).readUInt32BE(0);
|
||||||
rpcBuffer = chunk.slice(5);
|
rpcBuffer = chunk.subarray(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rpcBuffer.length >= rpcBufferSize) {
|
if (rpcBuffer.length >= rpcBufferSize) {
|
||||||
|
|||||||
Reference in New Issue
Block a user