PrismarineJS / node-minecraft-protocol

Parse and serialize minecraft packets, plus authentication and encryption.
https://prismarinejs.github.io/node-minecraft-protocol/
BSD 3-Clause "New" or "Revised" License
1.24k stars 239 forks source link

Fix serialization issue in old version for mc server test #1337

Open rom1504 opened 1 month ago

rom1504 commented 1 month ago

1) mc-server 1.12.2v kicks clients when invalid credentials: Uncaught RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 45. Received -847077210 at new NodeError (node:internal/errors:405:5) at boundsError (node:internal/buffer:88:9) at Buffer.readUInt8 (node:internal/buffer:254:5) at readVarInt (node_modules/protodef/src/datatypes/utils.js:68:22) at Splitter._transform (src/transforms/framing.js:63:30) at Transform._write (node_modules/readable-stream/lib/internal/streams/transform.js:153:8)

rom1504 commented 1 month ago

fyi @extremeheat

rom1504 commented 3 weeks ago

I think this is likely caused by recent node protodef changes https://github.com/ProtoDef-io/node-protodef/commits/master/

extremeheat commented 3 weeks ago

Only change in ProtoDef was how the compiler inlined anonymous containers (treats them as normal containers then merges object into parent), so I don't think it would affect anything big.

Would need to see what packet specifically is causing the error and the dumped buffer to reproduce (the stack trace here is limited to only a few lines it seems)

rom1504 commented 3 weeks ago

https://github.com/ProtoDef-io/node-protodef/commit/fcf3ca0568eb8cc0d0167c79db454572165da3f7 was also recently released

rom1504 commented 3 weeks ago

https://github.com/PrismarineJS/mineflayer/issues/3492 mentions packet advancement

rom1504 commented 3 weeks ago

For 1.21 wonder if it could be https://github.com/PrismarineJS/node-minecraft-protocol/blob/master/src/datatypes/compiler-minecraft.js#L44