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/index.js
CHANGED
|
@@ -207,8 +207,10 @@
|
|
|
207
207
|
}
|
|
208
208
|
}
|
|
209
209
|
const nestedDecodeErrors = new WeakSet();
|
|
210
|
+
let arrayAllocationBudget;
|
|
210
211
|
function checkedRead() {
|
|
211
212
|
try {
|
|
213
|
+
arrayAllocationBudget = srcEnd - position$1;
|
|
212
214
|
let result = read();
|
|
213
215
|
if (bundledStrings$1) {
|
|
214
216
|
if (position$1 >= bundledStrings$1.postBundlePosition)
|
|
@@ -398,7 +400,9 @@
|
|
|
398
400
|
if (token > maxArraySize) throw new Error(`Array length exceeds ${maxArraySize}`)
|
|
399
401
|
// every element occupies at least one byte, so a length beyond what remains in the source can
|
|
400
402
|
// never be satisfied; check before allocating so a tiny header can not force a huge allocation
|
|
401
|
-
|
|
403
|
+
// nested arrays each pass the check above yet still preallocate, so also spend from a
|
|
404
|
+
// per-decode budget of the remaining bytes; the summed lengths of any valid tree stay under it
|
|
405
|
+
if (token > srcEnd - position$1 || (arrayAllocationBudget -= token) < 0) throw endOfCBORError()
|
|
402
406
|
let array = new Array(token);
|
|
403
407
|
//if (currentDecoder.keyMap) for (let i = 0; i < token; i++) array[i] = currentDecoder.decodeKey(read())
|
|
404
408
|
//else
|
|
@@ -1185,6 +1189,7 @@
|
|
|
1185
1189
|
let savedDecoder = currentDecoder;
|
|
1186
1190
|
let savedSequentialMode = sequentialMode;
|
|
1187
1191
|
let savedRestoreMapsAsObject = restoreMapsAsObject;
|
|
1192
|
+
let savedArrayAllocationBudget = arrayAllocationBudget;
|
|
1188
1193
|
restoreMapsAsObject = false;
|
|
1189
1194
|
try {
|
|
1190
1195
|
return callback()
|
|
@@ -1201,6 +1206,7 @@
|
|
|
1201
1206
|
currentStructures = savedStructures;
|
|
1202
1207
|
currentDecoder = savedDecoder;
|
|
1203
1208
|
restoreMapsAsObject = savedRestoreMapsAsObject;
|
|
1209
|
+
arrayAllocationBudget = savedArrayAllocationBudget;
|
|
1204
1210
|
dataView = new DataView(src.buffer, src.byteOffset, src.byteLength);
|
|
1205
1211
|
}
|
|
1206
1212
|
}
|