Skip to content

Commit

Permalink
Limit client flags to server capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisBraun committed Oct 27, 2023
1 parent fa47d0b commit b037997
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/commands/server_handshake.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ServerHandshake extends Command {

readClientReply(packet, connection) {
// check auth here
const clientHelloReply = Packets.HandshakeResponse.fromPacket(packet);
const clientHelloReply = Packets.HandshakeResponse.fromPacket(packet, this.args.capabilityFlags);
// TODO check we don't have something similar already
connection.clientHelloReply = clientHelloReply;
if (this.args.authCallback) {
Expand Down
4 changes: 2 additions & 2 deletions lib/packets/handshake_response.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ class HandshakeResponse {
const p = this.serializeResponse(Packet.MockBuffer());
return this.serializeResponse(Buffer.alloc(p.offset));
}
static fromPacket(packet) {
static fromPacket(packet, serverFlags) {
const args = {};
args.clientFlags = packet.readInt32();
function isSet(flag) {
return args.clientFlags & ClientConstants[flag];
return (args.clientFlags & serverFlags) & ClientConstants[flag];
}
args.maxPacketSize = packet.readInt32();
args.charsetNumber = packet.readInt8();
Expand Down

0 comments on commit b037997

Please sign in to comment.