Avoid unnecessary allocations
This commit is contained in:
parent
26ff48bb15
commit
1ffbda8eb4
|
@ -7,12 +7,16 @@ require('colors');
|
|||
|
||||
function restrictPath(receiver, binding, count, args) {
|
||||
const dapp = dappPath();
|
||||
const tmp = os.tmpdir();
|
||||
const allowedRoots = [
|
||||
dapp,
|
||||
os.tmpdir()
|
||||
];
|
||||
|
||||
let allInsideRestricted = true;
|
||||
|
||||
for(let i = 0; i < count; i++) {
|
||||
let resolved = path.resolve(dapp, args[i]);
|
||||
allInsideRestricted = [dapp, tmp].some(p => { return resolved.indexOf(p) === 0; });
|
||||
allInsideRestricted = allowedRoots.some(p => { return resolved.indexOf(p) === 0; });
|
||||
if(!allInsideRestricted) break;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue