@atom-js-org/cli 0.4.1-alpha.0 → 0.4.2-alpha.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atom-js-org/cli",
3
- "version": "0.4.1-alpha.0",
3
+ "version": "0.4.2-alpha.0",
4
4
  "description": "CLI for running and building AtomJS desktop applications.",
5
5
  "bin": {
6
6
  "atom": "bin/atom.cjs"
package/src/build.cjs CHANGED
@@ -106,7 +106,7 @@ async function localBuild(project, target, options = {}) {
106
106
  }
107
107
 
108
108
  const manifest = {
109
- atomjsVersion: '0.3.0-alpha.0',
109
+ atomjsVersion: '0.4.2-alpha.0',
110
110
  target,
111
111
  productName,
112
112
  appId: project.config.appId,
@@ -367,19 +367,32 @@ function readPortableExecutableLayout(image) {
367
367
  }
368
368
 
369
369
  const peOffset = image.readUInt32LE(0x3c);
370
- if (peOffset < 0x40 || peOffset + 0x100 > image.length || image.toString('ascii', peOffset, peOffset + 4) !== 'PE\\0\\0') {
370
+ const coffHeaderSize = 24;
371
+ if (peOffset < 0x40 || peOffset + coffHeaderSize > image.length || image.readUInt32LE(peOffset) !== 0x00004550) {
371
372
  throw new Error('AtomJS expected a Windows PE executable but the PE header is invalid.');
372
373
  }
373
374
 
374
- const optionalHeaderOffset = peOffset + 24;
375
+ const optionalHeaderSize = image.readUInt16LE(peOffset + 20);
376
+ const optionalHeaderOffset = peOffset + coffHeaderSize;
377
+ const optionalHeaderEnd = optionalHeaderOffset + optionalHeaderSize;
378
+ if (optionalHeaderSize < 2 || optionalHeaderEnd > image.length) {
379
+ throw new Error('AtomJS expected a complete Windows PE optional header.');
380
+ }
381
+
375
382
  const magic = image.readUInt16LE(optionalHeaderOffset);
376
383
  if (magic !== 0x10b && magic !== 0x20b) {
377
384
  throw new Error(`AtomJS does not support Windows PE optional-header magic 0x${magic.toString(16)}.`);
378
385
  }
379
386
 
387
+ const dataDirectoryOffset = optionalHeaderOffset + (magic === 0x20b ? 112 : 96);
388
+ const certificateDirectoryEnd = dataDirectoryOffset + (8 * 5);
389
+ if (certificateDirectoryEnd > optionalHeaderEnd) {
390
+ throw new Error('AtomJS expected the Windows PE certificate data directory.');
391
+ }
392
+
380
393
  return {
381
394
  optionalHeaderOffset,
382
- dataDirectoryOffset: optionalHeaderOffset + (magic === 0x20b ? 112 : 96)
395
+ dataDirectoryOffset
383
396
  };
384
397
  }
385
398
 
@@ -783,4 +796,4 @@ function xml(value) {
783
796
  return String(value).replace(/[<>&'\"]/g, (char) => ({ '<': '&lt;', '>': '&gt;', '&': '&amp;', "'": '&apos;', '"': '&quot;' })[char]);
784
797
  }
785
798
 
786
- module.exports = { buildCommand, localBuild, createApplicationPayload };
799
+ module.exports = { buildCommand, localBuild, createApplicationPayload, readPortableExecutableLayout };
package/src/init.cjs CHANGED
@@ -30,14 +30,14 @@ async function initCommand(directory, options = {}) {
30
30
  start: 'atom run build'
31
31
  },
32
32
  dependencies: {
33
- '@atom-js-org/runtime': '0.3.0-alpha.0',
34
- electron: 'npm:@atom-js-org/electron@0.3.0-alpha.0'
33
+ '@atom-js-org/runtime': '0.4.2-alpha.0',
34
+ electron: 'npm:@atom-js-org/electron@0.4.2-alpha.0'
35
35
  },
36
36
  optionalDependencies: {
37
37
  'webview-nodejs': '0.5.0'
38
38
  },
39
39
  devDependencies: {
40
- '@atom-js-org/cli': '0.3.0-alpha.0'
40
+ '@atom-js-org/cli': '0.4.2-alpha.0'
41
41
  },
42
42
  overrides: {
43
43
  tar: '7.5.20'