Merge branch 'n1073645-debExtractor'

This commit is contained in:
n1474335 2020-03-06 15:59:59 +00:00
commit a770d09687

View file

@ -1724,6 +1724,25 @@ export const FILE_SIGNATURES = {
},
extractor: null
},
{
name: "Jar Archive",
extension: "jar",
mime: "application/java-archive",
description: "",
signature: {
0: 0x50,
1: 0x4B,
2: 0x03,
3: 0x04,
4: 0x14,
5: 0x00,
6: 0x08,
7: 0x00,
8: 0x08,
9: 0x00
},
extractor: extractZIP
},
{
name: "lzop compressed",
extension: "lzop,lzo",
@ -1742,7 +1761,7 @@ export const FILE_SIGNATURES = {
extractor: extractLZOP
},
{
name: "Linux deb",
name: "Linux deb package",
extension: "deb",
mime: "application/vnd.debian.binary-package",
description: "",
@ -1755,7 +1774,7 @@ export const FILE_SIGNATURES = {
5: 0x68,
6: 0x3e
},
extractor: null
extractor: extractDEB
},
{
name: "Apple Disk Image",
@ -3448,6 +3467,37 @@ export function extractXZ(bytes, offset) {
}
/**
* DEB extractor.
*
* @param {Uint8Array} bytes
* @param {Number} offset
*/
export function extractDEB(bytes, offset) {
const stream = new Stream(bytes.slice(offset));
// Move past !<arch>
stream.moveForwardsBy(8);
while (stream.hasMore()) {
// Move to size field.
stream.moveForwardsBy(48);
let fsize= "";
// Convert size to a usable number.
for (const elem of stream.getBytes(10)) {
fsize += String.fromCharCode(elem);
}
fsize = parseInt(fsize.trim(), 10);
// Move past `\n
stream.moveForwardsBy(2);
stream.moveForwardsBy(fsize);
}
return stream.carve();
}
/**
* ELF extractor.
*