cbor-x 1.6.7 → 1.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/decode.js +7 -1
- package/dist/decode-no-eval.cjs +7 -1
- package/dist/decode-no-eval.cjs.map +1 -1
- package/dist/index-no-eval.cjs +7 -1
- package/dist/index-no-eval.cjs.map +1 -1
- package/dist/index-no-eval.min.js +1 -1
- package/dist/index-no-eval.min.js.map +1 -1
- package/dist/index.js +7 -1
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/node.cjs +7 -1
- package/dist/node.cjs.map +1 -1
- package/dist/test.js +7 -1
- package/dist/test.js.map +1 -1
- package/package.json +1 -1
package/dist/test.js
CHANGED
|
@@ -210,8 +210,10 @@
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
const nestedDecodeErrors = new WeakSet();
|
|
213
|
+
let arrayAllocationBudget;
|
|
213
214
|
function checkedRead() {
|
|
214
215
|
try {
|
|
216
|
+
arrayAllocationBudget = srcEnd - position$1;
|
|
215
217
|
let result = read();
|
|
216
218
|
if (bundledStrings$1) {
|
|
217
219
|
if (position$1 >= bundledStrings$1.postBundlePosition)
|
|
@@ -401,7 +403,9 @@
|
|
|
401
403
|
if (token > maxArraySize) throw new Error(`Array length exceeds ${maxArraySize}`)
|
|
402
404
|
// every element occupies at least one byte, so a length beyond what remains in the source can
|
|
403
405
|
// never be satisfied; check before allocating so a tiny header can not force a huge allocation
|
|
404
|
-
|
|
406
|
+
// nested arrays each pass the check above yet still preallocate, so also spend from a
|
|
407
|
+
// per-decode budget of the remaining bytes; the summed lengths of any valid tree stay under it
|
|
408
|
+
if (token > srcEnd - position$1 || (arrayAllocationBudget -= token) < 0) throw endOfCBORError()
|
|
405
409
|
let array = new Array(token);
|
|
406
410
|
//if (currentDecoder.keyMap) for (let i = 0; i < token; i++) array[i] = currentDecoder.decodeKey(read())
|
|
407
411
|
//else
|
|
@@ -1222,6 +1226,7 @@
|
|
|
1222
1226
|
let savedDecoder = currentDecoder;
|
|
1223
1227
|
let savedSequentialMode = sequentialMode;
|
|
1224
1228
|
let savedRestoreMapsAsObject = restoreMapsAsObject;
|
|
1229
|
+
let savedArrayAllocationBudget = arrayAllocationBudget;
|
|
1225
1230
|
restoreMapsAsObject = false;
|
|
1226
1231
|
try {
|
|
1227
1232
|
return callback()
|
|
@@ -1240,6 +1245,7 @@
|
|
|
1240
1245
|
currentStructures = savedStructures;
|
|
1241
1246
|
currentDecoder = savedDecoder;
|
|
1242
1247
|
restoreMapsAsObject = savedRestoreMapsAsObject;
|
|
1248
|
+
arrayAllocationBudget = savedArrayAllocationBudget;
|
|
1243
1249
|
dataView = new DataView(src.buffer, src.byteOffset, src.byteLength);
|
|
1244
1250
|
}
|
|
1245
1251
|
}
|