fixed extract bug when filename is exactly 100 chars
This commit is contained in:
parent
0042359203
commit
4d1e031a7c
1 changed files with 11 additions and 11 deletions
22
headers.js
22
headers.js
|
@ -68,11 +68,11 @@ var alloc = function(size) {
|
||||||
return buf;
|
return buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
var indexOf = function(block, num, offset) {
|
var indexOf = function(block, num, offset, end) {
|
||||||
for (; offset < block.length; offset++) {
|
for (; offset < end; offset++) {
|
||||||
if (block[offset] === num) return offset;
|
if (block[offset] === num) return offset;
|
||||||
}
|
}
|
||||||
return -1;
|
return end;
|
||||||
};
|
};
|
||||||
|
|
||||||
var cksum = function(block) {
|
var cksum = function(block) {
|
||||||
|
@ -88,11 +88,11 @@ var encodeOct = function(val, n) {
|
||||||
};
|
};
|
||||||
|
|
||||||
var decodeOct = function(val, offset) {
|
var decodeOct = function(val, offset) {
|
||||||
return parseInt(val.slice(offset, clamp(indexOf(val, 32, offset), val.length, val.length)).toString(), 8);
|
return parseInt(val.slice(offset, clamp(indexOf(val, 32, offset, val.length), val.length, val.length)).toString(), 8);
|
||||||
};
|
};
|
||||||
|
|
||||||
var decodeStr = function(val, offset) {
|
var decodeStr = function(val, offset, length) {
|
||||||
return val.slice(offset, indexOf(val, 0, offset)).toString();
|
return val.slice(offset, indexOf(val, 0, offset, offset+length)).toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
var addLength = function(str) {
|
var addLength = function(str) {
|
||||||
|
@ -178,19 +178,19 @@ exports.decode = function(buf) {
|
||||||
|
|
||||||
if (!type) return null;
|
if (!type) return null;
|
||||||
|
|
||||||
var name = decodeStr(buf, 0);
|
var name = decodeStr(buf, 0, 100);
|
||||||
var mode = decodeOct(buf, 100);
|
var mode = decodeOct(buf, 100);
|
||||||
var uid = decodeOct(buf, 108);
|
var uid = decodeOct(buf, 108);
|
||||||
var gid = decodeOct(buf, 116);
|
var gid = decodeOct(buf, 116);
|
||||||
var size = decodeOct(buf, 124);
|
var size = decodeOct(buf, 124);
|
||||||
var mtime = decodeOct(buf, 136);
|
var mtime = decodeOct(buf, 136);
|
||||||
var linkname = buf[157] === 0 ? null : decodeStr(buf, 157);
|
var linkname = buf[157] === 0 ? null : decodeStr(buf, 157, 100);
|
||||||
var uname = decodeStr(buf, 265);
|
var uname = decodeStr(buf, 265, 32);
|
||||||
var gname = decodeStr(buf, 297);
|
var gname = decodeStr(buf, 297, 32);
|
||||||
var devmajor = decodeOct(buf, 329);
|
var devmajor = decodeOct(buf, 329);
|
||||||
var devminor = decodeOct(buf, 337);
|
var devminor = decodeOct(buf, 337);
|
||||||
|
|
||||||
if (buf[345]) name = decodeStr(buf, 345)+'/'+name;
|
if (buf[345]) name = decodeStr(buf, 345, 155)+'/'+name;
|
||||||
|
|
||||||
if (cksum(buf) !== decodeOct(buf, 148)) return null;
|
if (cksum(buf) !== decodeOct(buf, 148)) return null;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue