Skip to content

Commit

Permalink
Read header with Pickle
Browse files Browse the repository at this point in the history
  • Loading branch information
lafkpages committed Oct 30, 2023
1 parent 9c2eb07 commit ba10619
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/asar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,17 @@ export class Asar extends DirectoryEntry {
if (asarBytes) {
// Read header size
debug(2, "[new Asar] Reading header size");
const headerSize =
createFromBuffer(asarBytes.subarray(0, 16))
.createIterator()
.readUInt32() + 16;
const headerSize = createFromBuffer(asarBytes.subarray(0, 8))
.createIterator()
.readUInt32();
debug(2, "[new Asar] Header size:", headerSize);

// Read header
// We start at 16 because 0-8 are the Pickle object containing
// the header size, and 9-15 are the header size itself
// We start at 8 because 0-8 are the Pickle object containing the header size
debug(2, "[new Asar] Reading header");
const rawHeader = asarBytes.subarray(16, headerSize).toString();
const rawHeader = createFromBuffer(asarBytes.subarray(8, 8 + headerSize))
.createIterator()
.readString();
const header = JSON.parse(rawHeader) as unknown;

if (opts.noHeaderTypeChecks) {
Expand Down

0 comments on commit ba10619

Please sign in to comment.