mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
035e06317a
When built with Python 3.9 on IBM i, `process.platform` will return `os400` instead of `aix`. In preparation for this, make `common.isAIX` only return true for AIX and update the tests to add checks for `common.isIBMi` where they were missing. PR-URL: https://github.com/nodejs/node/pull/48056 Refs: https://github.com/nodejs/node/pull/46739 Refs: https://github.com/nodejs/build/pull/3358 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
47 lines
1.5 KiB
JavaScript
47 lines
1.5 KiB
JavaScript
'use strict';
|
|
|
|
// This is a regression test for some scenarios in which node would pass
|
|
// unsanitized user input to a printf-like formatting function when dlopen
|
|
// fails, potentially crashing the process.
|
|
|
|
const common = require('../common');
|
|
const tmpdir = require('../common/tmpdir');
|
|
tmpdir.refresh();
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
|
|
// This error message should not be passed to a printf-like function.
|
|
assert.throws(() => {
|
|
process.dlopen({ exports: {} }, 'foo-%s.node');
|
|
}, ({ name, code, message }) => {
|
|
assert.strictEqual(name, 'Error');
|
|
assert.strictEqual(code, 'ERR_DLOPEN_FAILED');
|
|
if (!common.isAIX && !common.isIBMi) {
|
|
assert.match(message, /foo-%s\.node/);
|
|
}
|
|
return true;
|
|
});
|
|
|
|
const notBindingDir = 'test/addons/not-a-binding';
|
|
const notBindingPath = `${notBindingDir}/build/Release/binding.node`;
|
|
const strangeBindingPath = `${tmpdir.path}/binding-%s.node`;
|
|
// Ensure that the addon directory exists, but skip the remainder of the test if
|
|
// the addon has not been compiled.
|
|
fs.accessSync(notBindingDir);
|
|
try {
|
|
fs.copyFileSync(notBindingPath, strangeBindingPath);
|
|
} catch (err) {
|
|
if (err.code !== 'ENOENT') throw err;
|
|
common.skip(`addon not found: ${notBindingPath}`);
|
|
}
|
|
|
|
// This error message should also not be passed to a printf-like function.
|
|
assert.throws(() => {
|
|
process.dlopen({ exports: {} }, strangeBindingPath);
|
|
}, {
|
|
name: 'Error',
|
|
code: 'ERR_DLOPEN_FAILED',
|
|
message: /^Module did not self-register: '.*binding-%s\.node'\.$/
|
|
});
|