FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

sea: reject trailing content in config JSON · nodejs/node@64a8843 · GitHub

/ node Public

Commit 64a8843

Browse files
authored andcommitted
sea: reject trailing content in config JSON
Ensure the on-demand parser reaches the end of the document after reading the root object. Reject concatenated JSON values with TRAILING_CONTENT Signed-off-by: Archkon <180910180+Archkon@users.noreply.github.com> PR-URL: #64774 Reviewed-By: Aviv Keller <me@aviv.sh>
1 parent d8a0f28 commit 64a8843

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

‎src/node_sea.cc‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,14 @@ std::optional<SeaConfig> ParseSingleExecutableConfig(
541541
}
542542
}
543543

544+
if (!document.at_end()) {
545+
FPrintF(stderr,
546+
"Cannot parse JSON from %s: %s\n",
547+
config_path,
548+
simdjson::error_message(simdjson::TRAILING_CONTENT));
549+
return std::nullopt;
550+
}
551+
544552
if (static_cast<bool>(result.flags & SeaFlags::kUseSnapshot) &&
545553
static_cast<bool>(result.flags & SeaFlags::kUseCodeCache)) {
546554
// TODO(joyeecheung): code cache in snapshot should be configured by

‎test/sea/test-single-executable-blob-config-errors.js‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,24 @@ const { spawnSyncAndAssert } = require('../common/child_process');
4747
});
4848
}
4949

50+
{
51+
tmpdir.refresh();
52+
const config = tmpdir.resolve('trailing-content.json');
53+
writeFileSync(
54+
config,
55+
'{"main":"bundle.js","output":"sea.blob"}{}',
56+
'utf8',
57+
);
58+
spawnSyncAndAssert(
59+
process.execPath,
60+
['--experimental-sea-config', config], {
61+
cwd: tmpdir.path,
62+
}, {
63+
status: 1,
64+
stderr: /TRAILING_CONTENT/,
65+
});
66+
}
67+
5068
{
5169
tmpdir.refresh();
5270
const config = tmpdir.resolve('empty.json');

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL