Skip to content

Commit cb7a509

Browse files
asklarCopilot
andcommitted
Fix binary fields in FolderEntryId, StoreEntryId, and UUID fields
- providerUID, databaseGuid, wrappedProvider now output as hex strings instead of raw bytes with unprintable characters - OnThisComputerOnly uuid and ApplyRetentionPolicy guid also fixed - Strip null padding from dllFileName ('EMSMDB.DLL\0\0\0\0' -> 'EMSMDB.DLL') Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 4930f31 commit cb7a509

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/rule-element-data.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ export class FolderEntryId extends FlatEntry {
6161
if (this.size !== 0) {
6262
this.flags = sb.readUInt32();
6363
softAssert(this.flags === 0);
64-
this.providerUID = sb.readAsciiString(16);
64+
this.providerUID = sb.readBytes(16).toString('hex');
6565
this.folderType = sb.readUInt16();
66-
this.databaseGuid = sb.readAsciiString(16);
66+
this.databaseGuid = sb.readBytes(16).toString('hex');
6767
this.globalCounter = sb.readUInt64().toString();
6868
}
6969
sb.offset = pos + this.size + 4;
@@ -86,16 +86,16 @@ export class StoreEntryId extends FlatEntry {
8686
super(sb);
8787
this.flags = sb.readUInt32();
8888
softAssert(this.flags === 0);
89-
this.providerUID = sb.readAsciiString(16);
89+
this.providerUID = sb.readBytes(16).toString('hex');
9090
this.version = sb.readUInt8();
9191
softAssert(this.version === 0);
9292
this.flag = sb.readUInt8();
9393
softAssert(this.flags === 0);
94-
this.dllFileName = sb.readAsciiString(14);
95-
softAssert(this.dllFileName === 'EMSMDB.DLL\0\0\0\0');
94+
this.dllFileName = sb.readAsciiString(14).replace(/\0+$/, '');
95+
softAssert(this.dllFileName === 'EMSMDB.DLL');
9696
this.wrappedFlags = sb.readUInt32();
9797
softAssert(this.wrappedFlags === 0);
98-
this.wrappedProvider = sb.readAsciiString(16);
98+
this.wrappedProvider = sb.readBytes(16).toString('hex');
9999
this.wrappedType = sb.readUInt32();
100100
softAssert(this.wrappedType === 0xc);
101101
this.serverShortName = sb.readAsciiUntilNullTerminator();
@@ -292,7 +292,7 @@ export class ApplyRetentionPolicyRuleElementData extends RuleElementData {
292292
public constructor(sb: StreamBuffer) {
293293
super(sb); this.extended = sb.readUInt32(); softAssert(this.extended === 1);
294294
this.reserved = sb.readUInt32(); softAssert(this.reserved === 0);
295-
this.followUp = sb.readUInt32(); this.guid = sb.readAsciiString(16);
295+
this.followUp = sb.readUInt32(); this.guid = sb.readBytes(16).toString('hex');
296296
this.name = sb.readStringObject();
297297
}
298298
}
@@ -302,7 +302,7 @@ export class OnThisComputerOnlyRuleElementData extends RuleElementData {
302302
public constructor(sb: StreamBuffer) {
303303
super(sb); this.extended = sb.readUInt32(); softAssert(this.extended === 1);
304304
this.reserved = sb.readUInt32(); softAssert(this.reserved === 0);
305-
this.uuid = sb.readAsciiString(16);
305+
this.uuid = sb.readBytes(16).toString('hex');
306306
}
307307
}
308308

test/rule-element-data.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,6 @@ describe('OnThisComputerOnlyRuleElementData', () => {
114114
const payload = Buffer.concat([u32(1), u32(0), uuid]);
115115
const sb = new StreamBuffer(payload);
116116
const data = new OnThisComputerOnlyRuleElementData(sb);
117-
expect(data.uuid.length).toBe(16);
117+
expect(data.uuid.length).toBe(32); // 16 bytes as hex
118118
});
119119
});

0 commit comments

Comments
 (0)