Skip to content

Commit 82335b1

Browse files
committed
version bump 0.5.0: scan directory first
basic parse tests pass
1 parent 3bc2923 commit 82335b1

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

Diff for: cfb.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,10 @@ for(j = 0; blob.l != 512; ) {
240240

241241

242242
/** Break the file up into sectors */
243-
if(file.length%ssz!==0) console.error("CFB: size " + file.length + " % "+ssz);
244-
245243
var nsectors = Math.ceil((file.length - ssz)/ssz);
246244
var sectors = [];
247-
for(var i=1; i != nsectors + 1; ++i) sectors[i-1] = file.slice(i*ssz,(i+1)*ssz);
245+
for(var i=1; i != nsectors; ++i) sectors[i-1] = file.slice(i*ssz,(i+1)*ssz);
246+
sectors[nsectors-1] = file.slice(nsectors*ssz)
248247

249248
/** Chase down the rest of the DIFAT chain to build a comprehensive list
250249
DIFAT chains by storing the next sector number as the last 32 bytes */
@@ -282,11 +281,11 @@ function get_next_sector(idx) { return get_buffer_u32(idx); }
282281
var chkd = new Array(sectors.length), sector_list = [];
283282
var get_sector = function get_sector(k) { return sectors[k]; };
284283
for(i=0; i != sectors.length; ++i) {
285-
var buf = [];
286-
if(chkd[i]) continue;
287-
for(j=i; j<=MAXREGSECT; buf.push(j),j=get_next_sector(j)) chkd[j] = true;
288-
sector_list[i] = {nodes: buf};
289-
sector_list[i].data = Array(buf.map(get_sector)).toBuffer();
284+
var buf = [], k = (i + dir_start) % sectors.length;
285+
if(chkd[k]) continue;
286+
for(j=k; j<=MAXREGSECT; buf.push(j),j=get_next_sector(j)) chkd[j] = true;
287+
sector_list[k] = {nodes: buf};
288+
sector_list[k].data = Array(buf.map(get_sector)).toBuffer();
290289
}
291290
sector_list[dir_start].name = "!Directory";
292291
if(nmfs > 0 && minifat_start !== ENDOFCHAIN) sector_list[minifat_start].name = "!MiniFAT";
@@ -335,7 +334,7 @@ function read_directory(idx) {
335334
} else {
336335
o.storage = 'minifat';
337336
w = o.start * mssz;
338-
if(minifat_store !== ENDOFCHAIN) {
337+
if(minifat_store !== ENDOFCHAIN && o.start !== ENDOFCHAIN) {
339338
o.content = sector_list[minifat_store].data.slice(w,w+o.size);
340339
prep_blob(o.content);
341340
}

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cfb",
3-
"version": "0.4.0",
3+
"version": "0.5.0",
44
"author": "Niggler",
55
"description": "Compound File Binary File Format extractor",
66
"keywords": [ "cfb", "compression", "office" ],

0 commit comments

Comments
 (0)