From 2392e3c7e2c482eb6bbdf333243ba93bf1c91c6f Mon Sep 17 00:00:00 2001 From: wanqifei Date: Fri, 1 Nov 2024 17:32:44 +0800 Subject: [PATCH] fix: fix wrong length number write to packet --- lib/packets/packet.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/packets/packet.js b/lib/packets/packet.js index 42241ae950..4a111180ff 100644 --- a/lib/packets/packet.js +++ b/lib/packets/packet.js @@ -830,11 +830,10 @@ class Packet { if (n === null) { return this.writeInt8(0xfb); } - // TODO: check that n is out of int precision this.writeInt8(0xfe); - this.buffer.writeUInt32LE(n, this.offset); + this.buffer.writeUInt32LE(n & 0xffffffff, this.offset); this.offset += 4; - this.buffer.writeUInt32LE(n >> 32, this.offset); + this.buffer.writeUInt32LE(Math.floor(n / 0x100000000), this.offset); this.offset += 4; return this.offset; }