bplist-parser
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -0,7 +1,9 @@ | ||
/* eslint-disable no-console */ | ||
'use strict'; | ||
// adapted from http://code.google.com/p/plist/source/browse/trunk/src/com/dd/plist/BinaryPropertyListParser.java | ||
// adapted from https://github.com/3breadt/dd-plist | ||
const fs = require('fs'); | ||
const bigInt = require("big-integer"); | ||
const bigInt = require('big-integer'); | ||
const debug = false; | ||
@@ -22,3 +24,3 @@ | ||
const parseFile = exports.parseFile = function (fileNameOrBuffer, callback) { | ||
exports.parseFile = function (fileNameOrBuffer, callback) { | ||
return new Promise(function (resolve, reject) { | ||
@@ -100,3 +102,3 @@ function tryParseBuffer(buffer) { | ||
// For the format specification check | ||
// <a href="http://www.opensource.apple.com/source/CF/CF-635/CFBinaryPList.c"> | ||
// <a href="https://www.opensource.apple.com/source/CF/CF-635/CFBinaryPList.c"> | ||
// Apple's binary property list parser implementation</a>. | ||
@@ -166,15 +168,16 @@ function parseObject(tableOffset) { | ||
const length = Math.pow(2, objInfo); | ||
if (objInfo == 0x4) { | ||
if (length < exports.maxObjectSize) { | ||
const data = buffer.slice(offset + 1, offset + 1 + length); | ||
const str = bufferToHexString(data); | ||
return bigInt(str, 16); | ||
if (length === 16) { | ||
const str = bufferToHexString(data); | ||
return bigInt(str, 16); | ||
} | ||
return data.reduce((acc, curr) => { | ||
acc <<= 8; | ||
acc |= curr & 255; | ||
return acc; | ||
}); | ||
} else { | ||
throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); | ||
} | ||
if (objInfo == 0x3) { | ||
return buffer.readInt32BE(offset + 1); | ||
} | ||
if (length < exports.maxObjectSize) { | ||
return readUInt(buffer.slice(offset + 1, offset + 1 + length)); | ||
} | ||
throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); | ||
} | ||
@@ -187,3 +190,3 @@ | ||
} | ||
throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); | ||
throw new Error("Too little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); | ||
} | ||
@@ -202,3 +205,3 @@ | ||
} else { | ||
throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); | ||
throw new Error("Too little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); | ||
} | ||
@@ -236,3 +239,3 @@ } | ||
} | ||
throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); | ||
throw new Error("Too little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); | ||
} | ||
@@ -249,3 +252,3 @@ | ||
if (intType != 0x1) { | ||
console.err("UNEXPECTED LENGTH-INT TYPE! " + intType); | ||
console.error("UNEXPECTED LENGTH-INT TYPE! " + intType); | ||
} | ||
@@ -271,3 +274,3 @@ const intInfo = int_type & 0x0F; | ||
} | ||
throw new Error("To little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); | ||
throw new Error("Too little heap space available! Wanted to read " + length + " bytes, but only " + exports.maxObjectSize + " are available."); | ||
} | ||
@@ -294,3 +297,3 @@ | ||
if (length * objectRefSize > exports.maxObjectSize) { | ||
throw new Error("To little heap space available!"); | ||
throw new Error("Too little heap space available!"); | ||
} | ||
@@ -324,3 +327,3 @@ const array = []; | ||
if (length * 2 * objectRefSize > exports.maxObjectSize) { | ||
throw new Error("To little heap space available!"); | ||
throw new Error("Too little heap space available!"); | ||
} | ||
@@ -327,0 +330,0 @@ if (debug) { |
{ | ||
"name": "bplist-parser", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Binary plist parser.", | ||
@@ -20,3 +20,4 @@ "main": "bplistParser.js", | ||
"devDependencies": { | ||
"mocha": "^6.1.4" | ||
"eslint": "6.5.x", | ||
"mocha": "6.2.x" | ||
}, | ||
@@ -33,4 +34,4 @@ "homepage": "https://github.com/nearinfinity/node-bplist-parser", | ||
"dependencies": { | ||
"big-integer": "^1.6.44" | ||
"big-integer": "1.6.x" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 8 instances in 1 package
632
0
23512
2
6
Updatedbig-integer@1.6.x