imagescript 4.2.1 → 4.2.2

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.
@@ -1022,10 +1022,14 @@ function fromWOFF(data) {
1022
1022
  const view = new DataView(data.buffer, data.byteOffset, data.byteLength);
1023
1023
  const count = view.getUint16(12);
1024
1024
  const tables = [];
1025
+ let budget = 1 << 27;
1025
1026
  for (let i = 0; i < count; i++) {
1026
1027
  const e = 44 + i * 20, offset = view.getUint32(e + 4), compressed = view.getUint32(e + 8), length = view.getUint32(e + 12);
1027
1028
  if (offset + compressed > data.length)
1028
1029
  throw new Error('Font: damaged or truncated font data');
1030
+ if (length > budget)
1031
+ throw new Error('Font: WOFF tables are too large');
1032
+ budget -= length;
1029
1033
  const raw = data.subarray(offset, offset + compressed);
1030
1034
  let table = raw;
1031
1035
  if (compressed < length) {
@@ -1035,6 +1039,8 @@ function fromWOFF(data) {
1035
1039
  catch (err) {
1036
1040
  throw new Error('Font: damaged WOFF table', { cause: err });
1037
1041
  }
1042
+ if (table.length !== length)
1043
+ throw new Error('Font: damaged WOFF table');
1038
1044
  }
1039
1045
  tables.push({ tag: view.getUint32(e), checksum: view.getUint32(e + 16), data: table });
1040
1046
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imagescript",
3
- "version": "4.2.1",
3
+ "version": "4.2.2",
4
4
  "description": "Pure TypeScript image processing that runs everywhere",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",