Fix zerocoder, use buffers instead of strings for vardata, add util for null-terminated string<->buffer conversion
This commit is contained in:
@@ -17,7 +17,7 @@ export class DirClassifiedQueryMessage implements MessageBase
|
||||
};
|
||||
QueryData: {
|
||||
QueryID: UUID;
|
||||
QueryText: string;
|
||||
QueryText: Buffer;
|
||||
QueryFlags: number;
|
||||
Category: number;
|
||||
QueryStart: number;
|
||||
@@ -38,7 +38,7 @@ export class DirClassifiedQueryMessage implements MessageBase
|
||||
this.QueryData['QueryID'].writeToBuffer(buf, pos);
|
||||
pos += 16;
|
||||
buf.writeUInt8(this.QueryData['QueryText'].length, pos++);
|
||||
buf.write(this.QueryData['QueryText'], pos);
|
||||
this.QueryData['QueryText'].copy(buf, pos);
|
||||
pos += this.QueryData['QueryText'].length;
|
||||
buf.writeUInt32LE(this.QueryData['QueryFlags'], pos);
|
||||
pos += 4;
|
||||
@@ -67,13 +67,13 @@ export class DirClassifiedQueryMessage implements MessageBase
|
||||
this.AgentData = newObjAgentData;
|
||||
const newObjQueryData: {
|
||||
QueryID: UUID,
|
||||
QueryText: string,
|
||||
QueryText: Buffer,
|
||||
QueryFlags: number,
|
||||
Category: number,
|
||||
QueryStart: number
|
||||
} = {
|
||||
QueryID: UUID.zero(),
|
||||
QueryText: '',
|
||||
QueryText: Buffer.allocUnsafe(0),
|
||||
QueryFlags: 0,
|
||||
Category: 0,
|
||||
QueryStart: 0
|
||||
@@ -81,7 +81,7 @@ export class DirClassifiedQueryMessage implements MessageBase
|
||||
newObjQueryData['QueryID'] = new UUID(buf, pos);
|
||||
pos += 16;
|
||||
varLength = buf.readUInt8(pos++);
|
||||
newObjQueryData['QueryText'] = buf.toString('utf8', pos, pos + (varLength - 1));
|
||||
newObjQueryData['QueryText'] = buf.slice(pos, pos + (varLength - 1));
|
||||
pos += varLength;
|
||||
newObjQueryData['QueryFlags'] = buf.readUInt32LE(pos);
|
||||
pos += 4;
|
||||
|
||||
Reference in New Issue
Block a user